创建 jar 后,nimbus 的外观和感觉不会出现

发布于 2024-11-28 10:11:46 字数 1141 浏览 3 评论 0原文

创建 jar 后,nimbus 的外观和感觉不会出现 当我在 NetBeans 中运行程序时 Nimbus 看起来 &感觉工作完美,但是当我创建 Jar 并从 jar 运行应用程序时,nimbus 看起来&感觉没有出现 代码:

public static void main(String[] args)
{

     boolean isNimbus = false;
try {

    for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
    {
        if ("Nimbus".equals(info.getName()))
        {
            UIManager.setLookAndFeel(info.getClassName());
            isNimbus = true;
            break;
        }
    }
    if(!isNimbus)
    {
       UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }

    } catch (ClassNotFoundException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
    Dashboard dashboardObj = new Dashboard();
}

nimbus look and feel not appear after creating jar
when i run program in NetBeans at time Nimbus look & Feel work perfectly but when i create Jar and run Application from jar at time nimbus look & feel is not appear
CODE:

public static void main(String[] args)
{

     boolean isNimbus = false;
try {

    for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
    {
        if ("Nimbus".equals(info.getName()))
        {
            UIManager.setLookAndFeel(info.getClassName());
            isNimbus = true;
            break;
        }
    }
    if(!isNimbus)
    {
       UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }

    } catch (ClassNotFoundException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
    Dashboard dashboardObj = new Dashboard();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

予囚 2024-12-05 10:11:46

Nimbus,Java SE 6 更新中引入的跨平台外观。因此,请检查您是否在 jdk 6 中编译 java 代码并在 jre 6 中运行它

,在 cmd 中键入:

java -version

以检查 jre 的当前版本

Nimbus, a cross platform look and feel introduced in the Java SE 6 update. So check that you are compile your java code in jdk 6 and run it in jre 6

type this in cmd:

java -version

to check current version of your jre

鼻尖触碰 2024-12-05 10:11:46

如果在 NetBeans 中工作正常,但运行 jar 文件时未出现 LAF,则可能意味着未在类路径中正确发现 LAF 库。由于我不知道您的设置,因此我无法提出正确的答案。您可以在运行 jar 文件时调整类路径设置(通过 jar -cp ...)或将应用程序打包为单个 jar,并包含所有依赖项 - < a href="http://one-jar.sourceforge.net/" rel="nofollow">onejar 是实现此目的的便捷方法。

If it works fine in NetBeans, but the LAF does not appear, when running a jar file, it probably means that the LAF library wasn't correctly discovered in the classpath. Since I don't know your setup, I can't really suggest the right answer. You could adjust your classpath settings when running the jar file (via jar -cp ...) or package your application as a single jar, with all the dependencies included - onejar is a convenient way to accomplish this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文