Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting look and feel in Swing app after startup

 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • 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
 
Rob Camick
Ranch Hand
Posts: 2619
9
  • Mark post as helpful
  • send pies
  • 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
  • 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

 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic