Java GUI外观变化 [英] Java GUI look and feel changes

查看:164
本文介绍了Java GUI外观变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编程新手,但我正准备编写一个Java程序。正如我正在计划的那样,我正在努力为它找到合适的GUI。我找到了页面,带有GUI选项。我有两个问题:

I'm new to programming, but I'm preparing to write a Java program. As I'm planning it, I'm trying to find the right GUI for it. I found this page with GUI options. I have two questions:


  1. 这些只是插入Java GUI构建器吗?

  2. 多么容易(或者很难)是在构建程序后更改GUI的外观吗?


推荐答案

更改程序的外观非常简单:

Changing the look and feel of a program is as simple as:

UIManager.setLookAndFeel("fully qualified name of look and feel");

在创建任何GUI创建代码之前。因此,您可以使用GUI构建器轻松创建所有GUI,然后在程序开始时调用它。

before any GUI-creating code has been created. So you can easily create all your GUI with your GUI builder and then simply call this at the start of your program.

(请注意,有些外观和感觉,如Substance,在线程问题上非常严格,所以你最好确保所有的GUI代码都是从事件调度线程运行的。)

(Note that some look and feels, like Substance, are very strict when it comes to threading issues, so you better make sure that all your GUI code is run from the event dispatching thread.)

作为一个建议,两个非常看起来很好看(而且看起来足够专业)外观和感觉是Substance和Nimbus,它将随后发布的JRE作为默认的外观N-feel(至少是那个计划),可以单独下载java.net。

As a suggestion, two very good looking (and professional looking enough) look and feels in my opinion are Substance and also Nimbus which will ship with later releases of the JRE as the default look-N-feel (at least that's the plan) and which can be downloaded separately from java.net.

因此,如果您选择使用Nimbus,代码将是:

So if you opt for Nimbus the code would be:

UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");

物质的一个例子(物质有很多皮肤和主题,如果你想了解更多,请阅读他们的其网站上的文档)将是:

And one example of Substance (Substance has many skins and themes, if you want to know more read their documentation in their site) would be:

UIManager.setLookAndFeel(new org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel());

另请注意,您可以像这样使用跨平台皮肤(金属):

Also note that you can use the cross platform skin (Metal) like this:

UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());

最后,如果你在Windows上,你可以使用系统外观和感觉:

And finally if you are on windows you can use the system look and feel like this:

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

这篇关于Java GUI外观变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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