JFormDesigner / FlatLaf

FlatLaf - Swing Look and Feel (with Darcula/IntelliJ themes support)
https://www.formdev.com/flatlaf/
Apache License 2.0
3.42k stars 272 forks source link

TabbedPane selectedBackground changes when JFrame looses and regains focus. #593

Closed gitpicard closed 2 years ago

gitpicard commented 2 years ago

I have changed the background color on selection of the TabbedPane via UIManager.put("TabbedPane.selectedBackground", Color.TRANSLUCENT);

This works just fine until I select a different app and then return to the app. After that the selected background color changes back to the accent default. Is there anything that can be done about this or a quick fix?

gitpicard commented 2 years ago

For reference, the demo jar has this bug as well. Happens on Windows 11.

DevCharly commented 2 years ago

Color.TRANSLUCENT is not a color. This is an int and therefor ignored by FlatLaf.

What you're probably seeing is the focused background, which is show when the tabbed pane is focused:

image

Please try with a real color. E.g.

UIManager.put("TabbedPane.selectedBackground", Color.GREEN);
gitpicard commented 2 years ago

https://user-images.githubusercontent.com/42253330/192009281-c978c455-3e63-4618-a64e-536c0788e913.mp4

I made a short clip of the issue. In this instance I commented out the code for the background selected color. As you can see, the simple act of switching focus changes the color.

DevCharly commented 2 years ago

Sorry, still don't see an issue here.

Looks like initially no component is focused. Switching to other tabs does not focus the tabbed pane. (only clicking selected tab moves focus to tabbed pane) Then the window is deactivated and activated, which moves the focus to the first focusable component, which is the tabbed pane. The orange tab background is color of TabbedPane.focusColor, right?

If you select tab "Neues Project" and then click at "Projectname" text field, then focus should move to that text field and the orange tab background should be gone, right?