Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use two different look and feels in the same Swing application?

I'm using the Flamingo ribbon and the Substance Office 2007 look and feel.

Of course now every control has this look and feel, even those on dialog boxes.

What I want is something like in Office 2007, where the ribbons have their Office 2007 look, but other controls keep their native Vista/XP look.

Is it possible to assign certain controls a different look and feel? Perhaps using some kind of chaining or a proxy look and feel?

like image 734
Daniel Rikowski Avatar asked Jan 15 '09 08:01

Daniel Rikowski


People also ask

Does swing support multiple look and feels?

Swing provides platform specific Look and Feel and also an option for pluggable Look and Feel, allowing application to have Look and Feel independent of underlying platform.

What is pluggable look and feel what is its importance?

Pluggable look and feel is a mechanism used in the Java Swing widget toolkit allowing to change the look and feel of the graphical user interface at runtime.


2 Answers

I just discovered: Since Substance 5.0 the SKIN_PROPERTY is available.

It allows assigning different skins to different JRootPanes (i.e. JDialog, JFrame, JInternalFrame)

A little trick: I override JInternalFrame to remove the extra border and the title pane so that it looks just like a borderless panel. That way it is possible to create the impression, that different parts of a form/dialog have different looks.

like image 60
Daniel Rikowski Avatar answered Sep 28 '22 14:09

Daniel Rikowski


Here is a library which will automaticaly change the look and feel. I am not sure it this will done for every component in a different way, but you should take a look at it. pbjar.org

This book should be useful if you want to go deep into look and feel /java-look-and-feel-design-guidelines-second-edition

I would be glad to see some code example, if someone can write it, feel free to get starting.

EDIT:

In this forum thread Thread i found the following description

Swing uses a Look & Feel (a PLAF). PLAFs aren't attached on a per-JFrame level. They are attached on a per-VM level. It is almost impossible to mix PLAFs within one application. I have seen a few attempts, all failed.

like image 42
Markus Lausberg Avatar answered Sep 28 '22 12:09

Markus Lausberg