"JAVA" Uimnager

Source: Internet
Author: User
Tags gtk

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.