I've written a handy method to frame a panel so I can test how it looks, but what I'm finding is that when I try to call it, on the first window that comes up, the JButtons don't have the correct look and feel. Subsequent windows are OK.
I thought maybe the look and feel wasn't loading fully before the frame was displayed, but I put a Thread.sleep in there to give it time, and that didn't help.
Also tried Nimbus look and feel, and get the same problem.
Taking the setLookAndFeel method out all together results in the default Metal displaying OK. It looks like the first window's buttons have no look and feel set at all.
By the way, I also tried this on my laptop (windows XP) and by compiling from the command prompt, and it still happens, so you should be able to reproduce this.
Gah... I've sort-of figured it out. Nothing to do with threads or timing or final variables. It seems that if I create a JButton before the Look and Feel is set, it doesn't get displayed properly. If I create the buttons *after* the first panel has been framed (and the look and feel set), they do.
So in the following code, Button 1 is displayed incorrectly, but Button 2 is correct.
If I change the main to the following, neither displays correctly.
If I set the Look and Feel in the main method instead, it works OK.
But I want to keep the framePanel method in a separate utility class... seems I have no alternative but to take out the look-and-feel setting and do it before I create any components?
I was under the impression you could set the look and feel at any time before you make components visible, but is would seem not.