我正在使用 NetBeans 及其 GUI 编辑器开发一个简单的 Java 应用程序。
我坚持创建一个简单的对话框:运行时它看起来与我设计的以及编辑器中预览的不同。
基本上,单击按钮就会出现我的对话框。
private void jButton1MouseReleased(java.awt.event.MouseEvent evt) {
PanelDialogNuovoCliente pan = new PanelDialogNuovoCliente();
JDialog jd=new JDialog();
jd.setTitle("Nuovo Cliente");
jd.setMinimumSize(new Dimension(500, 400));
jd.setLocationRelativeTo(null);
jd.add(pan);
jd.setModal(true);
jd.setVisible(true);
}
问题是,当对话框出现时,它具有不同的外观,对话框窗口看起来更小,并且并非所有组件都适合其中。
PanelDialogNuovoCliente
只是一个JPanel
带有一些标签和JTextField
.
最大、最小和首选大小均设置为 (500,400)JPanel
编辑器中的属性。
JDialog
从我截取的代码中,最小大小设置为(500,400)。
不幸的是,我无法发布屏幕截图,因为我需要至少 10 个信誉,但是当我运行应用程序时,对话框的窗口比我从 NetBean 的 GUI 编辑器中的预览按钮看到的窗口要小。
EDIT: Here's the screenshot. Runtime JDialog is on the left, while preview of it in netbeans is on the right. I tried to call JDialog#pack() just before setVisible(true) without success. I set nimbus look and feel for my app. Anyways if i try to preview the design from ide with nimbus l&f it looks perfect so i don't think that this one is the real problem