Please use code tags next time. Unformated codes are really hard to read. If you don't know how to do that, check my forum signature.

12-23-2010, 03:31 AM

Fubarable

Quote:

Originally Posted by MarkusHendersonicus

Hi folks, I was just wondering how, in the following example, I'd make button1 appear on the JFrame. I've put "THIS DOESN'T WORK!" after my attempt which is commented out at this time...

Please define "this doesn't work" for us, because if we don't know how it's not working, we can't help you.

Also, you'll want to read the Oracle Swing tutorials layout manager section where you'll see that a JFrame's contentPane uses BorderLayout by default, and what BorderLayout's behavior is.

12-23-2010, 03:33 AM

Eranga

You've put some comments. Identify that the comment and the rest of the code are relevant too.

12-23-2010, 05:19 AM

MarkusHendersonicus

Sorry folks! Basically, when the following line is allowed to execute

frame.getContentPane().add (button1); // THIS DOESN'T WORK!

I would expect a JButton to appear in addition to the already displayed JTable. However, what actually happens is that the JTable vanishes and a very thin JButton appears instead! I have no idea why at this point.