mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.13k stars 234 forks source link

Transparent Icon Button / Slider ? #639

Closed mokun closed 3 years ago

mokun commented 3 years ago

Hi,

How do I get rid of the pale pink background that comes with the WebButton ?

image

I'd like to create button that has a transparent background so that whatever icon image inside the button would appear to "float" on top of background panel.

Can it be done using weblaf and how ?

See below. I saw in the demo that there is a class called IconButton.

image

I guess the fourth row of button are NOT transparent. But at least, it appears so.

When I hover my mouse pointer over it, the pink background color shows up.

Without the mouse hovering over it, it doesn't show.

mgarin commented 3 years ago

You can use basic StyleId.buttonUndecorated style:

WebButton undecorated = new WebButton ( StyleId.buttonUndecorated );

You can provide that style in WebButton constructor or set it later at any point in runtime.

You can also apply style to JButton if you don't want any direct WebLaF dependencies: https://github.com/mgarin/weblaf/wiki/How-to-style-Swing-components

P.S. It's not pink - it's light gray:

<GradientBackground>
    <color>white</color>
    <color>223,223,223</color>
</GradientBackground>

:)

mokun commented 3 years ago

WebButton undecorated = new WebButton ( StyleId.buttonUndecorated );
..

The StyleId.buttonUndecorated work well. See below.

image

Question, is there a weblaf enhancement of the plain ol' JSlider in Swing ?

Any quick tips on replacing the color scheme, especially, making it transparent and floating, just like the WebButtton above ?

mgarin commented 3 years ago

I haven't fully moved slider to new styling system, so it would be quite hard to change it looks right now. There are some settings you can modify in custom slider style coming from SliderPainter class, but those won't help in this particular case.

You can follow #493 to get updates on the slider changes once they go live.

mgarin commented 3 years ago

I'll close this question as it should now be answered. Adjusting slider view will become possible once #493 is implemented (possibly in v1.2.15 update).