Java Swing theme

Java does not set the theme by default, it can be said that the page is very ugly, the following aspects can be improved

In the main method of startup add:

 

// Metal风格 (默认)
String lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";
UIManager.setLookAndFee(lookAndFeel);

// Windows风格
String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
UIManager.setLookAndFee(lookAndFeel);  

// Windows Classic风格
String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
UIManager.setLookAndFee(lookAndFeel);  

// Motif风格
String lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
UIManager.setLookAndFeel(lookAndFeel);

// Mac style (requires implementation on the relevant operating system) 
String lookAndFeel = "com.sun.java.swing.plaf.mac.MacLookAndFeel" ;
UIManager.setLookAndFeel(lookAndFeel);

// GTK style (which needs to be implemented on the relevant operating system) 
String lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" ;
UIManager.setLookAndFeel(lookAndFeel);

// Cross-platform default style 
String lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
UIManager.setLookAndFeel(lookAndFeel); 
// The style of the current system String lookAndFeel = UIManager.getSystemLookAndFeelClassName(); UIManager.setLookAndFeel(lookAndFeel);
copy code

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326043545&siteId=291194637