1

Is is possible to have a different LAF in a eg. JPanel and all its children?

The core of my program (all within a single JPanel) heavily relies on heights and widths of components (which are changed trought different LAFs), therefore has to have a constant LAF. Rest of it could have any LAF (eg. platforms native LAF).

?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Karlovsky120
  • 6,212
  • 8
  • 41
  • 94
  • An alternative would be not to rely heavily on heights and widths of components you don't paint yourself ;-) Also note that mixing LAFs will make your application look terrible. – John Dvorak May 29 '14 at 03:13
  • No, it won't. The JPanel I'm talking about is something similar to MS Word workspace (the area that displays pages). And only component with any visible change is JTextArea. But since it's used as an editor-input kinda thing, it doesn't really feel out of place. And since I'm then printing the whole thing to PDF, I have to hardcode the heights, because I want all files from diferent users on diferent platforms to have the same alignement values. There is a reason for everything. – Karlovsky120 May 29 '14 at 03:25
  • It might be possible to set an LAF for a hidden frame that you make, but I'm not sure it's possible to set LAF for individual components. – John Dvorak May 29 '14 at 03:27
  • Could you hide the frame part of a frame and lock its position to an existing one? – Karlovsky120 May 29 '14 at 03:38
  • You can have borderless windows, but it feels like a hack anyways. – John Dvorak May 29 '14 at 03:40

1 Answers1

1

I'm not a big L&F guru, but IMHO it's not possible. Even when you traverse the component tree and set your own UI for each component, this will work until the updateUI make a reset. Another big problem is deafult settings. Some settings (like colors, insets or fonts) are stored in a static map. So your panel will use wrong colors, fonts, insets and some other settings.

Sergiy Medvynskyy
  • 11,160
  • 1
  • 32
  • 48
  • Correct, although you can borrow the odd element, as shown [here](http://stackoverflow.com/a/14262706/230513). – trashgod May 29 '14 at 14:43