سؤال

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.

هل كانت مفيدة؟

المحلول

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.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top