Search code examples
javaswingnetbeanslook-and-feelnimbus

My JFrame appears in basic design not in advanced design in java netbeans


Recently I made a desktop application for login system, I always run the program if i changed any code to be sure if this code is working well or not, Anyways when I run the program it always appears as an advanced design, I don't know what you call it.Let the images explain.

Basic design

http://www5.0zz0.com/2013/04/10/14/418370274.jpg

Advanced design

http://www5.0zz0.com/2013/04/10/14/868362737.jpg


Solution

  • Your basic design is basically Metal Look And Field and Advanced Design is Nimbus Look And Field so use the following code before creating object of the JFrame class.

    try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
    

    This code will change any look and field to Nimbus Look and Field