【发布时间】:2011-10-31 21:06:12
【问题描述】:
在another thread 中,我表示我喜欢通过执行以下操作来使我的 GUI 居中:
JFrame frame = new JFrame("Foo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new HexagonGrid());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
但 Andrew Thompson 有不同的意见,改为致电
frame.pack();
frame.setLocationByPlatform(true);
好奇的人想知道为什么?
【问题讨论】:
-
gui 应该从上次结束的地方开始。
标签: java swing user-interface