Home > other >  How to set FlatLaf Light look and feel in NetBeans IDE 12.6
How to set FlatLaf Light look and feel in NetBeans IDE 12.6

Time:01-29

I haven't been able to find a solution to my problem for 3 days. It’s about adjusting the look and feel option for my project. Nimbus and Metal do not suit my project and it turns out indescribably ugly while with FlatLaf Light it looks very nice because there are not many borders.

When I type FlatLaf Light nothing changes, it stays the same, I tried to find the answers on the official site. However, it was not successful.

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

CodePudding user response:

In a few simple steps I will explain the easiest possible:

  1. Enter this link: click me pls
  2. Download FlatLaf 1.2, why not a new version idk
  3. Create a folder in the folder where your project is located and insert the file there
  4. Go to NetBeans
  5. Find your project, and find the Library section
  6. Right-click and Add JAR / Folder and add FlatLaf 1.2
  7. Go to JFrame or anything in Main and insert this instead:

New fresh beautiful code

    public static void main(String args[]) {
    try {
        UIManager.setLookAndFeel(new FlatIntelliJLaf());
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Interface().setVisible(true);
            }
        });
    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(YourClassName.class.getName()).log(Level.SEVERE, null, ex);
    }
}

Old not juicy code (do not copy this dude)

public static void main(String args[]) {
    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(YourClassName.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(YourClassName.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(YourClassName.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(YourClassName.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new YourClassName().setVisible(true);
        }
    });
}

Damn, it works. Now dawg go playin this code, you know what I mean.

  •  Tags:  
  • Related