Netbeans JDialog size

ide, java, netbeans, swing, user-interface

Solution

I guess you might be using the Netbeans GUI builder, possible solutions/suggestions,

- You might be missing `dialog.pack();`

- Right click jDialog > Properties > (Set) minimumSize

- (Suggestion) Ditch the GUI Builder, learn Java instead of learning an IDE !

btw, this works for me ,

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class DialogsTest {

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                JFrame f = new JFrame();

                f.setSize(400, 300);
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.setVisible(true);

                JPanel message = new JPanel();
                message.add(new JLabel("This is a dialog :)"));
                JDialog dialog = new JDialog(f, "Dialog");

                dialog.setContentPane(message);
                dialog.pack();
                dialog.setLocationRelativeTo(f);
                dialog.setVisible(true);
            }
        });
    }
}

Problem

I'm creating a JDialog with netbeans as my IDE. I change the size to how I want it in netbeans, and I can see it updating the prefferredSize, but when I run my application it looks like this: Is there something else I need to set to set the size? Or at least make it sized properly so I can see the controls... (theres 6 on it)

Original source