0
votes

I have a JFrame in which constructor I call initComponents() generated by Netbeans. It initializes the GUI created in Netbean's design editor. After that I create a new JLabel and call content.add(label) where content is a JPanel which is visible. Next I call validate(). The JLabel won't appear. What's wrong?

1
What LayoutManager are you using? The default layout manager used by NetBeans is the Freeform layout manager. It was designed to used by the form editor and was not designed to be used by hand. It's possible that with the lack of constraints, your label is simply been ignoredMadProgrammer
Could be any number of things. Can you post your code?Reimeus
Thanks MadProgrammer! I changed the LayoutManager and it started working :)MikkoP
@MadProgrammer Please enter that as an answer.Andrew Thompson
Ah, I see you saw the comment now deleted. If you had read it carefully, you might have noticed the comment about 'snippets'. Anything less than the full code is no more than a 'bunch of snippets' - approximately as useless as just one snippet. Try reading all the comment, for better understanding.Andrew Thompson

1 Answers

5
votes

What LayoutManager are you using?

The default layout manager used by NetBeans is the Freeform layout manager.

It was designed to used by the form editor and was not designed to be used by hand.

It's possible that with the lack of constraints, your label is simply been ignored