在另一个线程中,我提到我喜欢通过以下方式使我的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);
有好奇心的人想知道为什么?