设置Swing程序的LookAndFeel,swinglookandfeel,在JDK中包含几个Loo
分享于 点击 30806 次 点评:97
设置Swing程序的LookAndFeel,swinglookandfeel,在JDK中包含几个Loo
在JDK中包含几个LookAndFeel类的子类,顾名思义,LookAndFeel类用来设置swing程序的外观的:
com.sun.java.swing.plaf.gtk.GTKLookAndFeeljavax.swing.plaf.metal.MetalLookAndFeelcom.sun.java.swing.plaf.windows.WindowsLookAndFeelcom.sun.java.swing.plaf.motif.MotifLookAndFeel
可以通过UIManager.setLookAndFeel("")
方法来设置swing程序的LookAndFeel
public static void main(String[] args) { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); } catch (Exception ex) { //Just print stacktrace here since it's an example. ex.printStackTrace(); } SwingUtilities.invokeLater(new Runnable() { public void run() { createTheGUIComponents(); } }); }
如果在某些form中设置成系统默认的外观,可以通过下面的方法设置:
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { //Just print stacktrace here since it's an example. ex.printStackTrace(); } SwingUtilities.invokeLater(new Runnable() { public void run() { createTheGUIComponents(); } }); }
用户点评