当按下按钮时,我正在从一个JDialog打开一个JFrame,这是我这样做的代码。
private JDialog FindView; ~~> JDialog declaration.
private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {
if (FindView == null) {
JFrame mainFrame = myApp.getApplication().getMainFrame();
FindView = new MyAppFindView(mainFrame, true);
FindView.setLocationRelativeTo(mainFrame);
}
myApp.getApplication().show(FindView);
}但是JDialog总是以相同的大小打开。如何调整JDialog的大小?
我检查了Form Size Policy,它是Generate pack()。
这是我在FindView java文件中设置的大小。

这就是它打开的大小。

解决了
最后一行代码似乎导致了问题。用FindView.setVisible(true);替换代码解决了这个问题。
发布于 2013-10-22 12:22:30
这应该可以做到:
JFrame mainFrame = myApp.getApplication().getMainFrame();
FindView = new MyAppFindView(mainFrame, true);
FindView.setLocationRelativeTo(mainFrame);
FindView.setPreferredSize(yourDimensions);https://stackoverflow.com/questions/19517526
复制相似问题