【问题标题】:How to set FlatLaf Light look and feel in NetBeans IDE 12.6如何在 NetBeans IDE 12.6 中设置 FlatLaf Light 外观
【发布时间】:2022-01-28 18:31:24
【问题描述】:

我已经 3 天没能找到解决问题的方法了。这是关于为我的项目调整外观选项。 Nimbus 和 Metal 不适合我的项目,结果变得难以形容,而使用 FlatLaf Light 看起来非常漂亮,因为没有太多边框。

当我输入 FlatLaf Light 时没有任何变化,它保持不变,我试图在官方网站上找到答案。然而,它并不成功。

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);
        }

【问题讨论】:

    标签: java swing user-interface


    【解决方案1】:

    我将通过几个简单的步骤来解释最简单的方法:

    1. 输入此链接:click me pls
    2. 下载 FlatLaf 1.2,为什么不是新版本 idk
    3. 在您的项目所在的文件夹中创建一个文件夹并将文件插入其中
    4. 转到 NetBeans
    5. 找到您的项目,然后找到库部分
    6. 右键单击并添加 JAR / 文件夹并添加 FlatLaf 1.2
    7. 转到 JFrame 或 Main 中的任何内容,然后将其插入:

    新的新鲜漂亮的代码

        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);
        }
    }
    

    旧而不多汁的代码(不要复制这个家伙)

    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);
            }
        });
    }
    

    该死的,它有效。现在 dawg 去玩这段代码,你懂我的意思。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-31
      • 1970-01-01
      相关资源
      最近更新 更多