I'm developing a simple Java application using NetBeans and its GUI editor. I'm stuck on creating a simple dialog: runtime it looks different from what I designed and from what is previewed in the editor. Basically, clicking on a button make my dialog appears.
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);
}
The problem is that when the dialog appears it has a different look, the dialog window seems smaller and not all the components fit in it.
PanelDialogNuovoCliente
is just a JPanel
with some labels and JTextField
.
Maximum, Minimum and Preferred sizes are all set to (500,400) from the JPanel
properties in the editor.
JDialog
minimum size is set to (500,400) from the code that I snipped.
Unfortunately I can't post a screenshot because I need at least 10 reputation but when I run the application Dialog's window is smaller compared to the one that I can see from the preview button in NetBean's GUI editor.
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