• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

setting look and feel in Swing app after startup

 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to change the look and feel of a Swing application under user control. I have the following code that almost works



The UI starts up in Metal / MoodyBlueTheme, and then switches to napkin; after I switch back, however, the drop-down box does not behave correctly in Metal any more. If I click on the arrow of the drop down and drag it down slowly, it paints some strange artifact that looks like an out-of-place element of the drop-down.

To run this you will need the napkin jar, or you can replace that L&F with some other one that you do have. I tried setting it to various other values (WindowsLookAndFeel, MotifLookAndFeel), but couldn't get Eclipse to recognize any of them, don't know what jar to put in the path for them.

Can someone tell me what I'm doing wrong here?
rc
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I tried setting it to various other values (WindowsLookAndFeel, MotifLookAndFeel), but couldn't get Eclipse to recognize any of them



You shouldn't need to do anything special. I used the following:

// UIManager.setLookAndFeel(new NapkinLookAndFeel());
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());



Also it didn't compile with the MoodyBlueTheme so I just used the OceanTheme. It workd fine for me.
 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks -- As I think you mean, after I was changing to "system look and feel" instead of napkin, it seems to work correctly. I *think* what that means is the napkin look and feel, at least the one I found and have, is faulty.

I like the idea of the napkin look and feel, but it doesn't seem to work correctly; you choose drop-downs and the background color of the panel changes, etc. But I didn't think it would affect how the other UI works after I changed back.

rc

 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I didn't think it would affect how the other UI works after I changed back.


Nimbus does that too, at least in Java 6. I don't know whether all the bugs have been ironed out in the version of Nimbus included with Java 7.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic