I am using the following code,
UIManager.put("JFrame.activeTitleBackground", Color.red);
to change toolbar color in JFrame. But that did not work.
Is it possible to change the title color in a JFrame?
Impossible. The top level of the JFrame is controlled by the appearance of the underlying OS.
You can change the color InternalFrame.
InternalFrame
//source : javax/swing/plaf/metal/MetalTitlePane.java import javax.swing.*; import javax.swing.plaf.*; import javax.swing.plaf.metal.*; public class TitleColor { public static void main_helper (String args[]) { JFrame f = new JFrame (); f.setDefaultCloseOperation ( JFrame.DISPOSE_ON_CLOSE ); f.setSize (300, 300); f.setLocationRelativeTo (null); f.setUndecorated ( true ); f.getRootPane ().setWindowDecorationStyle ( JRootPane.FRAME ); JPanel panel = new JPanel (); panel.setBackground ( java.awt.Color.white ); f.setContentPane ( panel ); DefaultMetalTheme z = new DefaultMetalTheme () { //inactive title color public ColorUIResource getWindowTitleInactiveBackground() { return new ColorUIResource (java.awt.Color.orange); } //active title color public ColorUIResource getWindowTitleBackground() { return new ColorUIResource (java.awt.Color.orange); } //start ActiveBumps public ColorUIResource getPrimaryControlHighlight() { return new ColorUIResource (java.awt.Color.orange); } public ColorUIResource getPrimaryControlDarkShadow() { return new ColorUIResource (java.awt.Color.orange); } public ColorUIResource getPrimaryControl() { return new ColorUIResource (java.awt.Color.orange); } //end ActiveBumps //start inActiveBumps public ColorUIResource getControlHighlight () { return new ColorUIResource (java.awt.Color.orange); } public ColorUIResource getControlDarkShadow () { return new ColorUIResource (java.awt.Color.orange); } public ColorUIResource getControl () { return new ColorUIResource (java.awt.Color.orange); } //end inActiveBumps }; MetalLookAndFeel.setCurrentTheme ( z ); try { UIManager.setLookAndFeel ( new MetalLookAndFeel () ); } catch (Exception e) { e.printStackTrace (); } SwingUtilities.updateComponentTreeUI (f); f.setVisible (true); } public static void main (final String args[]) { SwingUtilities.invokeLater ( new Runnable () { public void run () { main_helper ( args ); } } ); } }
UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(Color.black )); UIManager.put("InternalFrame.activeTitleForeground", new ColorUIResource(Color.WHITE)); UIManager.put("InternalFrame.titleFont", new Font("Dialog", Font.PLAIN, 11));
, , Win10. , - .
, Metal LAF, , , . Win10 win10, (), . Win10 .
f.setUndecorated(true); , , .
( : "", Swing LAF, LAF , . LAF , "" LAF (, win7) ( , win7 , ) , , Windows, Office 2016 "" Win 10. , , .)
In Windows10, in the main method, you can use:
UIDefaults uiDefaults = UIManager.getDefaults(); uiDefaults.put("activeCaption", new javax.swing.plaf.ColorUIResource(Color.gray)); uiDefaults.put("activeCaptionText", new javax.swing.plaf.ColorUIResource(Color.white)); JFrame.setDefaultLookAndFeelDecorated(true);
Source: https://habr.com/ru/post/1737806/More articles:How to catch exceptions from another program (for logging)? - c #Creating my own simple CMS for asp.net-mvc? - asp.net-mvcHow could I perform additional geometry operations along the bezier paths? - geometryWhat is the correct syntax for using mixed content HTML constructor in Groovy 1.7? - htmlHow to choose TOP 5 and then the next 5? - sqlHow to programmatically retrieve storage disk information in Linux? (C # MONO) - c #How to store inventory using Perl hashes? - perlHow to convert any text / font to its representation of the bezier path? - textSpring: introduce static member (System.in) through constructor - javaEuclidian Distances between points - pythonAll Articles