简体   繁体   English

没有灵气外观

[英]nimbus look and feel is not available

I created an gui application in netbeans 7.2 in java. 我在Java的netbeans 7.2中创建了一个gui应用程序。 I created a JFrame there. 我在那里创建了一个JFrame it was set to nimbus look and feel in auto generated code. 在自动生成的代码中将其设置为nimbus外观。 but my frame is not look like nimbus. 但我的框架看起来不像灵气。

so I debug the code and found nimbus is not available in the array returned by getInstalledLookAndFeels() . 所以我调试了代码,发现nimbus在getInstalledLookAndFeels()返回的数组中不可用。

so what should I do to install nimbus look and feel? 那么我该如何安装nimbus外观? JDK 1.6 used to compile the code. JDK 1.6用来编译代码。

Make sure your java version is greater than: JDK 6 Update 10. 确保您的Java版本大于:JDK 6 Update 10。

See here : 看这里

Nimbus is a polished cross-platform look and feel introduced in the Java SE 6 Update 10 (6u10) release. Nimbus是在Java SE 6 Update 10(6u10)发行版中引入的优美的跨平台外观。

you can download the latest Java (7u9) and Netbeans (7.2.1) versions (bundled) here: 您可以在此处下载最新的Java(7u9)和Netbeans(7.2.1)版本(捆绑):

After that you should be good to go, dont forget to set the L&F from within Event Disptach Thread too: 之后,您应该一切顺利,也不要忘记从Event Disptach Thread设置L&F:

    //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
        }

    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM