Friday 10 July 2015

Apply Look and feel in your Swing Java Application

Look and feel apply in main method
  
       
public static void main(String args[]) {
        
        try {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
            
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new SwingCalc().setVisible(true);
                }
            });
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(SwingCalc.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(SwingCalc.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(SwingCalc.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(SwingCalc.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

  
you also apply following method too
  
       
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

  

No comments:

Post a Comment