4

我在 java 的 netbeans 7.2 中创建了一个 gui 应用程序。我在JFrame那里创建了一个。它在自动生成的代码中设置为 nimbus 外观。但我的框架看起来不像灵气。

所以我调试了代码,发现 nimbus 在返回的数组中不可用getInstalledLookAndFeels()

那么我应该怎么做才能安装 nimbus 的外观和感觉呢?JDK 1.6 用于编译代码。

4

1 回答 1

6

确保您的 java 版本大于:JDK 6 Update 10。

见这里

Nimbus 是在 Java SE 6 Update 10 (6u10) 版本中引入的一种经过优化的跨平台外观。

您可以在此处下载最新的 Java (7u9) 和 Netbeans (7.2.1) 版本(捆绑):

之后你应该很高兴,不要忘记从内部设置 L&F Event Disptach Thread

    //Create UI and set L&F on EDT
    SwingUtilities.invokeLater(new Runnable( ) {
        public void run( ) {
                //set L&F
                try {
                       for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                           if ("Nimbus".equals(info.getName())) {
                                   UIManager.setLookAndFeel(info.getClassName());
                                   break;
                           }
                       }
                    } catch (Exception e) {
                    // If Nimbus is not available, you can set the GUI to another look and feel.
                     e.printStackTrace();
                    }
            //create UI and components here
        }

    });
于 2012-11-01T13:35:07.600 回答