0

I want to control the LookAndFeel of every component independently but I am not certain how to organize the code so the main frame of the program has one look and a pop-up window has another or even two pop-up windows have different LookAndFeels without overriding one another.

What are the methodologies to group LookAndFeels and apply them liberally across a program while maintaining tight control?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Mushy
  • 2,535
  • 10
  • 33
  • 54
  • 1
    From memory (took my SCJD about 10 years ago) the `javax.swing.UIManager`, where you set the LookAndFeel at, is a singleton. If that's indeed correct, I believe it would be impossible as setting the LAF multiple times would just set the same value. – CodeChimp Jan 08 '14 at 21:00
  • I think I confirmed it here: http://docs.oracle.com/javase/6/docs/api/javax/swing/UIManager.html#setLookAndFeel(javax.swing.LookAndFeel) . The method you set the LAF on is indeed a `static` method, which would seem to indicate that you can only set it globally for the application. – CodeChimp Jan 08 '14 at 21:02
  • Why would you want to set a different LAF into different components anyways? – Kayaman Jan 08 '14 at 21:16
  • I would highly recommend just extending swing to create the specific components you need inside a look and feel that does the majority of it right. It is time consuming but Swing provides one of the easiest methods for customizing your look and feel in my experience. If you look into Trident (I use FX and Qt now so my information is old) you can handle animations easily. Implementing your own look and feel is incredibly time consuming and I would highly recommend you look to newer frameworks which rely on CSS for styling. – Daniel B. Chapman Jan 08 '14 at 22:32
  • I recall a situation where mixing different PLAFs together itself cause problems. Search SO for the answers and comments of [kleopatra](http://stackoverflow.com/users/203657/kleopatra) for more details, there are few people who could give better advice on such matters, and they don't post to SO. OK - check [this answer](http://stackoverflow.com/a/18427362/418556) for starters.. – Andrew Thompson Jan 09 '14 at 01:30
  • While you can't mix whole components, you _can_ mix certain defaults, for [example](http://stackoverflow.com/a/14262706/230513). – trashgod Jan 09 '14 at 04:03

0 Answers0