让 Java 应用程序在 Windows 上看起来是原生的 - 如何? [英] Getting java applications to look native on windows - how?

查看:40
本文介绍了让 Java 应用程序在 Windows 上看起来是原生的 - 如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 Java 来创建在 Windows 上看起来是本机的应用程序?我不在乎解决方案是否可移植,因为我只打算针对 Windows 用户.如果重要的话,我正在使用 Scala.

Is it possible to use Java to create apps that look native on Windows? I don't care if the solution is portable or not, because I only plan to target windows users. I am using Scala if that matters.

抱歉缺少细节,但我之前从未使用过 Java,所以我什至不确定这是否可行.

Sorry for the lack of details, but I have never used Java before so I'm not even sure if this is possible.

推荐答案

try {
    // Set the Look and Feel of the application to the operating
    // system's look and feel.
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (ClassNotFoundException e) {
}
catch (InstantiationException e) {
}
catch (IllegalAccessException e) {
}
catch (UnsupportedLookAndFeelException e) {
}

这应该将外观设置为系统外观.您可以在任何 GUI 代码之前执行此操作.例如,在您的 main 方法中.

That should set the Look and Feel to the system look and feel. You would do this before any of your GUI code. For example, in your main method.

如果您想了解有关外观的更多信息,我会查看 Java 教程如洗车所建议.

If you want to learn more about Look and Feels, I would check out the Java Tutorial on them, as suggested by carwash.

这篇关于让 Java 应用程序在 Windows 上看起来是原生的 - 如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆