GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes setting look and feel in Swing app after startup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "setting look and feel in Swing app after startup" Watch "setting look and feel in Swing app after startup" New topic
Author

setting look and feel in Swing app after startup

Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
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

Joined: Jun 13, 2009
Posts: 2191
    
    7
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

Joined: May 29, 2005
Posts: 479
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

Joined: May 03, 2008
Posts: 4572
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
 
GeeCON Prague 2014
 
subject: setting look and feel in Swing app after startup