In NetBeans, I have used the GUI editor to make a JFrame and I\'ve put a JPanel in the frame. At the moment, I\'m trying to make a new button in the panel when the class con
Some times when you don't see a button it is a layout manager issue (as in you aren't setting the right properties for the layout manager). You can test this by disabling it:
this.jPanel2.setLayoutManager(null);
And setting bounds for the button (JButton.setBounds()
).
If the above fixes your problem, then you need to look into the requirements set by the LayoutManager you are using (see also the answer by Robin).
All the calls to validate()
, revalidate()
and repaint()
are not needed to do this.