swift
swift

Reputation: 363

Is it possible to set different look and feel for different panels within a same frame?

Say, I have 3 panels added to a frame and for the 1st panel i want to set the metal look and feel, for the 2nd panel I want windows look and feel, for the third panel it should be default swing style.

is it possible?

Upvotes: 4

Views: 3006

Answers (4)

Mordan
Mordan

Reputation: 337

What about loading UIManager.setLookAndFeel in a different classloader?

Wouldn't that work?

I guess if it works, you would need to bridge data between the classloaders. I think Google has written such a bridge.

Upvotes: 0

Kirill
Kirill

Reputation: 1

Actually it is possible, it's happening to me right now. In my GUI class, I've called

UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel")

For some reason, the container panel is still Metal, while all other components are Nimbus.

Upvotes: 0

Ash
Ash

Reputation: 9426

The javax.swing.UIManager class, where the look and feel is set, is a singleton. Only one can be set at any one time.

However, you can (if you're so inclined) override UI delegates on individual components (see JComponent.setUI()). Using this method you could probably hack together some components that use UI delegates of alternate look and feels. But in most cases they'll look up the UIDefaults set by the "real" look and feel, so at best it's probably going to be a poor approximation.

Upvotes: 5

Boris Pavlović
Boris Pavlović

Reputation: 64622

No, it's not possible.

Upvotes: 1

Related Questions