I've got an application which draws a background image on a panel, but to achieve the optimal UI, I need to set Component backgrounds Transparent:
I made every component transparent by using the UI Manager:
uimanager.put(Button, background(new color(0, 0, 0, 0); <- something like that, this works perfectly, except..
onMouseOver the component redraws itself (I guess) and causes Artifacts.. How can I avoid this in the UIManager?
(I created a class: uidefaults.java with all the UIManager settings)
Thanks in advance!!
Well, that is pretty simple - DO NOT use transparent background colors with components (any JComponent ancestor to be exact) that are OPAQUE.
To remove component background you don't need to set transparent color - just use this method:
This will hide component background and will also change component repaint strategy so it won't create any artifacts on repaint calls.
Also, if you still want to have semi-transparent background behind your component you can override paintComponent method like this:
This will force label to hide its default background and also paint your own background (that depends on component's background property).