This is the line that messes everything up:
jframe.setLayout(new FlowLayout());
You're changing the layout to FlowLayout
and then adding glcanvas
next to startButton
. The preferred size of glcanvas
is 0 so it is not visible, although you can see a slight movement of startButton
when the button is clicked.
I assume that setting FlowLayout
was not intentional because you are using BorderLayout.CENTER
constraint to add glcanvas
. So here is a simple fix:
Comment out:
//jframe.setLayout(new FlowLayout());
Add startButton
to the NORTH
of the panel instead of a CENTER
since glcanvas
will go to the CENTER
. Change:
jframe.add(startButton);
to:
jframe.add(startButton, BorderLayout.NORTH);
That fixed the revalidation issue, at least on Windows 7 Java 7.
Also, see A Visual Guide to Layout Managers for more details and examples about layouts.