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

Dear author, WebPopupMenu and WebComboBox ,How do I change the style to what I want? #674

Closed xcfdszzr closed 2 years ago

xcfdszzr commented 2 years ago

image use WebComboBox and WebPopupMenu ,I can't find any patterns that I need for example image

image

mgarin commented 2 years ago

Due to complexity and some minor issues - popup menu styling haven't been switched to fully-customizable scheme yet, but it should be possible to modify it to make it look like on your 2nd screenshot.

As you correctly noticed - popupmenu base style can be found in popupmenu.xml: https://github.com/mgarin/weblaf/blob/master/modules/ui/src/com/alee/skin/light/resources/popupmenu.xml It does have a limited amount of settings though because it is based on a custom PopupMenuPainter.

You can find all the properties you can specify in the popupmenu style in these two classes: https://github.com/mgarin/weblaf/blob/master/modules/ui/src/com/alee/laf/menu/PopupMenuPainter.java https://github.com/mgarin/weblaf/blob/master/modules/ui/src/com/alee/laf/menu/AbstractPopupPainter.java

Also it is important to note that combobox uses it's own variation of popupmenu style which can be found here: https://github.com/mgarin/weblaf/blob/master/modules/ui/src/com/alee/skin/light/resources/combobox.xml#L90 It doesn't modify the base one visually though, but it can be helpful in case you want to modify only combobox popup menu.

In the future - current default painter (PopupMenuPainter) will be replaced with a more customizable one to allow things like shape change, custom backgrounds, states support etc.

mgarin commented 2 years ago

To add to my previous answer - you need these settings to specifically replicate popup from your screenshot:

<painter>
    <popupStyle>simple</popupStyle>
    <background>white</background>
    <borderColor>white</borderColor>
    <round>0</round>
    <shadeWidth>6</shadeWidth>
    <shadeOpacity>0.5</shadeOpacity>
    <opacity>1</opacity>
</painter>

You can either apply these painter settings to default popupmenu style, to the combobox popup menu sub-style or to any other specific separate popupmenu style with a custom identifier.

mgarin commented 2 years ago

The original question should have been answered, so I'll be closing this issue