As a NetBeans novice, I’m laying out a pretty simple 2-panel GUI using NetBeans 7.0, and I’m having the craziest time getting some components (JButtons, JLabels, JSlider) to stay where I position them within the enclosing JPanel!
For example, when I drag one of the buttons to the upper left corner of its enclosing panel, I never see any guidelines, and when I release it, it zooms back toward the center of the panel, disturbing the placement of other components, and enlarging both the panel and, ultimately, the JFrame. It’s as if the button somehow imagines itself to be a lot larger, or to need a lot more room around its edges, then it really does.
I hope that’s enough information for someone with experience to readily diagnose my problem; otherwise I’ll try to answer follow-up questions.
It is recommended that you learn the Layout specifications and how things fit together before using a GUI builder. You could use your Netbeans as a sophisticated editor with file completion and debugger and write your first Swing code in regular classes, until you get the grasp of things.
Then you will appreciate better the capabilities of the tool.
Netbeans give you a default Free-Design Layout which is very easy to use graphically and although the generated code is kind of weird, the good news is that you will never have to deal with it.
You can add borders to your panels so you can see the behavior when you drag and drop components and resize the panels.