FlatLaf icon indicating copy to clipboard operation
FlatLaf copied to clipboard

Embedded Menu Bar and Active / Inactive Window

Open MerlinUKRhapsody opened this issue 1 year ago • 3 comments

If I embed the menu bar into the window - how do i change the color of the menu bar text when the window is inactive ? For example - An Inactive window has a blue background and white title text: image

An active window has an orange background and black title text - but I cant seem to change the menu text color and the white which looks great on the inactive window doesnt look so great now: image

MerlinUKRhapsody avatar Jun 27 '24 13:06 MerlinUKRhapsody

MenuBar.foreground

Wouldn't that be what you're looking for?

poce1don avatar Jun 28 '24 03:06 poce1don

Of course I've set that :) Its set to white Problem is there is no MenuBar.foregroundInactive (or similar). So while I can have two different backgrounds depending on wether the form is active or not - i cant do the same for menubar so i have to choose one color which looks good on either a dark or a light background - I would like to change the menubar color to be black if the window is active so it looks better on the orange - or white if the window is inactive so it looks better on the blue

MerlinUKRhapsody avatar Jun 28 '24 06:06 MerlinUKRhapsody

Then just add a WindowListener to your frame and call yourMenuBar.setForeground() in the windowActivated and windowDeactivated methods.

stackoverflow.com and ChatGPT also know a lot about this stuff.

remcopoelstra avatar Jun 29 '24 10:06 remcopoelstra

Ah yes I hadn't thought of that. I do use ChatGPT daily and I do perform exhaustive searching and experimentation to try and solve issues on my own before bothering you guys with questions ! I invented a new UIManager property 'MenuBar.inactiveForeground' and added a Window listener to grab the preferred colors on activation / deactivation of the owning window and apply them manually to the menu bar. It would be great if FlatLaf did this natively - after all thats why I'm using a theme so I don't have to manually apply colors but its solved my issue anyway so thanks !

MerlinUKRhapsody avatar Jul 01 '24 08:07 MerlinUKRhapsody