I've made a JComponent child from scratch and made basic- and metal-based look and feels for it. Even if I'm using the metal theme for the entire application, I still have to call setUI on the object to make it metal. Is there any way for it to use the current LnF if it's available and default to basic?
Asked
Active
Viewed 157 times
0
-
1don't mixing two L&Fs in one container, is possible but road to troubles, anyway for better help sooner post an [SSCCE](http://sscce.org/), short, runnable, compilble, just about a.m. issze – mKorbel Mar 28 '13 at 18:26
-
I'm not trying to mix them, I want the instances of the component I made to pick the right L&F automatically. My application is metal, by default, but if I simply add the component, it chooses the basic L&F. – Mar 28 '13 at 18:51
1 Answers
0
You can override updateUI()
in your JComponent
and install any custom settings you want:
@Override
public void updateUI() {
super.updateUI();
// customize here
}

Catalina Island
- 7,027
- 2
- 23
- 42
-
It extends `JComponent` directly, so `super.updateUI()` does nothing. I think because I'm doing all the drawing myself, I might just have to resign to using something like if (current theme is this) use this UI, etc. – Mar 29 '13 at 19:28
-
You're right about `super`; `JComponent#updateUI() is empty, too. – Catalina Island Apr 01 '13 at 13:09