我尝试了 setPreferedSize和setSize方法,但对话框仍然以最小尺寸打开。
private void method() {
commandDialog.setPreferredSize(new Dimension(100,100));
- - -
- - - //Components added to dialogPanel
commandDialog.add(dialogPanel);
// Tried this as well: commandDialog.setSize(40, 40);
commandDialog.validate();
commandDialog.setVisible(true);
}