Several look and feel in Java ' 1, metal style (default) String Lookandfeel = "Javax.swing.plaf.metal.MetalLookAndFeel"; Uimanager.setlookandfee (Lookandfeel);
2, Windows style String Lookandfeel = "Com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; Uimanager.setlookandfee
(Lookandfeel); 3, Windows classic style String Lookandfeel = "Com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
Uimanager.setlookandfeel (Lookandfeel);
4, motif style String Lookandfeel = "Com.sun.java.swing.plaf.motif.MotifLookAndFeel"; Uimanager.setlookandfeel (Lookandfeel);
5, Mac Style (need to be implemented above the relevant operating system) String Lookandfeel = "Com.sun.java.swing.plaf.mac.MacLookAndFeel";
Uimanager.setlookandfeel (Lookandfeel);
6, GTK style (need to be implemented above the relevant operating system) String Lookandfeel = "Com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
Uimanager.setlookandfeel (Lookandfeel);
7, the default style of cross-platform String lookandfeel = Uimanager.getcrossplatformlookandfeelclassname (); Uimanager.setlookandfeel
(Lookandfeel);
8, the current system style String Lookandfeel = Uimanager.getsystemlookandfeelclassname (); Uimanager.setlookandfeel (Lookandfeel);
In Java, allowing users to dynamically change the appearance of the application can give users a better experience, the specific implementation is: 1, first use the Uimanager.setlookandfeel (String s) method to set
2, then use the Swingutilities.updatecomponenttreeui (Component C) method to update the application immediately
DEMO package Com.star.update.lunach; import Javax.swing.jfilechooser;import Javax.swing.UIManager;import Javax.swing.unsupportedlookandfeelexception; public class Test { public static void main (string[] args) { System.out.println (Getjbosshomebychoose ()); } public Static String Getjbosshomebychoose () { Inituimanager (); jfilechooser filechooser = new JFileChooser ("D:"); Filechooser.setfileselectionmode (jfilechooser.directories_only); int returnval = FileChooser.showOpenDialog ( Filechooser); if (returnval = = jfilechooser.approve_option) { return filechooser.getselectedfile (). GetAbsolutePath (); } return null; } private static void Inituimanager () { String Lookandfeel = Uimanager.getsystemlookandfeelclassname (); try { uimanager.setlookandfeel ( Lookandfeel); } catch (ClassNotFoundException e) { e.printstacktrace (); } catch (InstAntiationexception e) { e.printstacktrace (); } catch (Illegalaccessexception e) { E.printstacktrace (); } catch (Unsupportedlookandfeelexception e) { e.printstacktrace (); } }}
"JAVA" Uimnager