0

So i used the following code to set the look and feel of my program to windows since i don't really like any of the themes like nimbus or the default swing theme but some component are still appearing with the old look and feel and not my windows LaF.

Code used:

try {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Windows".equals(info.getName())) {
            UIManager.setLookAndFeel(info.getClassName());
            break;
        }
    }
} catch (Exception e) {
}

However, some stuff like scroll bars and combo boxes still look like this:

1

Same with scroll bars, they are not like my windows's scroll bars.

Community
  • 1
  • 1
Nicolas Martel
  • 1,641
  • 3
  • 19
  • 34
  • 1) For better help sooner, post an [SSCCE](http://sscce.org/). 2) See [this answer](http://stackoverflow.com/a/5630271/418556) for code that can change PLAF at runtime. 3) The trick is probably either to change PLAF early, or call `updateComponentTreeUI` as in the linked example. – Andrew Thompson Nov 05 '12 at 00:53
  • *"set the look and feel of my program to windows since i don't really like.."* Are you the only user? Note that searching for `Windows` will find no matches on OS X & *nix boxes. – Andrew Thompson Nov 05 '12 at 00:55
  • For now i am the only one using it but it will be released to the public in the future though. I added the look and feel change before anything was initialized and that seems to have done the trick, thanks. – Nicolas Martel Nov 05 '12 at 00:58
  • You should use the "system look and feel" which defaults to windows on windows systems, but to the corresponding native look on other OSs – thedayofcondor Nov 05 '12 at 01:33

1 Answers1

3

I added the look and feel change before anything was initialized and that seems to have done the trick, ..

No worries, but see also getSystemLookAndFeelClassName() which is better than hard-coding Windows in that:

  • It will be reliable over time.
  • It will also work for OS X & *nix.
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433