Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submenu styling separate from top level menus #587

Closed
rkeen-siemens opened this issue Sep 9, 2022 · 1 comment
Closed

Submenu styling separate from top level menus #587

rkeen-siemens opened this issue Sep 9, 2022 · 1 comment
Milestone

Comments

@rkeen-siemens
Copy link

When customizing menu colors, you can change the selection color for a menu via Menu.selectionBackground and for a menu item via MenuItem.selectionBackground. However, it appears that Menu.selectionBackground applies to both the top level menu (e.g. JMenu in the menu bar) and any submenus (e.g. JMenu > JMenu in the drop down menu) as shown below.

Menu Colors

Is it possible to have a different color for top level menus and submenus? Or is there a way to have submenus use the menu item colors?

DevCharly added a commit that referenced this issue Sep 11, 2022
@DevCharly
Copy link
Collaborator

Yes, it is possible in latest 2.5-SNAPSHOT: https://github.com/JFormDesigner/FlatLaf#snapshots

There are two new UI properties MenuBar.selectionBackground and MenuBar.selectionForeground that are used for top level menus (JMenu components in JMenuBar). See also https://www.formdev.com/flatlaf/components/menubar/

Usage (for all menu bars):

UIManager.put( "MenuBar.selectionBackground", Color.green );
UIManager.put( "MenuBar.selectionForeground", Color.red );

Styling is also supported (for single menu bar):

menuBar.putClientProperty( "FlatLaf.style", "selectionBackground: #0f0; selectionForeground: #f00" );

@DevCharly DevCharly added this to the 2.5 milestone Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants