Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Get the system look and feel

import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class Main {   public static void main(String[] args) {     JFrame frame = new JFrame();     frame.setSize(300, 300);     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     frame.setTitle("System LAF Demo");     try {       UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());     } catch (ClassNotFoundException e) {       e.printStackTrace();     } catch (InstantiationException e) {       e.printStackTrace();     } catch (IllegalAccessException e) {       e.printStackTrace();     } catch (UnsupportedLookAndFeelException e) {       e.printStackTrace();     }     SwingUtilities.updateComponentTreeUI(frame);     frame.setVisible(true);   } }