Changing panel header color in Java Swing

I am running a Swing application on Win7 using a 144 dpi flat screen. My frame headers, options bar, etc. Displayed on a white background (Aero?). I like Aero in general, but white titles are very hard to read! I went through all the UIManager properties that I can think of, and none of them have any effect. Is there a level below the UIManager that I can get - and, preferably, make a one-time change for my application, since I do not want to add code for each individual panel call. Maybe I am missing something very simple ... but help will be appreciated!

I would also like to change the heading fonts, but this is not so urgent!

In addition to BTW, do you add UIManager.put calls before or after installing Look and Feel? Or is it not important?


Additional Information: I changed my personalization of Win7 to use an Aero theme called Canada, and the names are now in black, using a reasonable font. So my question is:

How do the UIManager attributes relate to Win7 themes, and given that I cannot predict which theme users will use, how can I control the appearance of the panel title?


I am going to ask this question in another way: why can I not change the color of each pixel in the application display panel? Is there a level below the UIManager that seems to be very limited in what you are allowed to change ...?

+6
source share
4 answers

This method will be a bit complicated, but if you need your own Container with full control,

1) create Un_decorated JFrame / JDialog

2) at the NORTH position, you can place a JPanel using GradientPaint , which mimics the container that came from Win7

3) and put 3 JButtons with an icon on JPanel using GradientPaint

4) add the necessary events to JButtons , and for more convenient output in the GUI, JButtons#setContentAreaFilled(false) will be set

+5
source

Use the setUndecorated(false) method to disable window decorations on the host platform.

The following is an example of this, although it is designed for the Mac OS platform, it can provide you with a starting point. Re-draw the transparent frame / panel / component.

+3
source

Perhaps this tutorial will help; he explains how to change the appearance of the JFrame. It also has a demo program, so you can explore the differences.

By default, the appearance of the JFrame design is controlled by the OS from this point on, applications are better suited with the overall appearance and platform of the platform used. But you can change it and control it yourself; there is no need to remove the decorations and "fake" them within your frame.

The disadvantage is that if you yourself determine the appearance of the scenery, and do not let the OS do it, you may have to think about which appearance and use so that your window does not encounter any application platform that can be launched.

+1
source

If you want to manage window decorators, use JFrame.setDefaultLookAndFeelDecorated (boolean) . Set this parameter to true , and then set โ€œLook and Feelโ€.

To see this work for you, first install the decorators (as described above), then select Look and Feel, which are more usable (although it may be ugly), for example Metal: Steel or Metal: Ocean:

 java -Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel -Dswing.metalTheme=steel MyApp.jar 

or

 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); 

By checking that this is what you want, you can go back and change the look and color palette.

0
source

Source: https://habr.com/ru/post/902492/


All Articles