Java 外观 (L&F)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3954616/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java Look and Feel (L&F)
提问by rajesh
I am developing a desktop application with Java Swing for my personal use.I am in need of some beautiful Look and Feel for my application. How can I do it using Java or a 3rd party API?
我正在使用 Java Swing 开发一个桌面应用程序供我个人使用。我的应用程序需要一些漂亮的外观。如何使用 Java 或 3rd 方 API 来实现?
采纳答案by Colin Hebert
There is a lot of possibilities for LaFs :
LaFs 有很多可能性:
- The nativefor your system
- The nimbusLaF
- Web LaF
- The substanceproject (forked into the Insubstantialproject)
- Napkin LaF
- Synthetica
- Quaqua(looks like aqua from MacOS X)
- Seaglass
- JGoodies
- Liquidlnf
- The Alloy Look and Feel
- PgsLookAndFeel
- JTatoo
- Jide look and feel
- etc.
- 您系统的本机
- 该灵气的LaF
- 网络LaF
- 该物质项目(分叉到非实质性项目)
- 餐巾纸
- 合成的
- Quaqua(看起来像 MacOS X 中的 aqua)
- 海玻璃
- JGoodies
- 液氮
- 合金外观
- 外观和感觉
- JTatoo
- 吉德外观
- 等等。
Resources :
资源 :
- Best Java Swing Look and Feel Themes | Top 10(A lot of the preview images on this page are now missing)
- oracle.com - Modifying the Look and Feel
- wikipedia.org - Pluggable look and feel
- Java2s.com - Look and feel
- 最佳 Java Swing 外观和感觉主题 | 前 10 名(此页面上的许多预览图像现在都丢失了)
- oracle.com - 修改外观
- wikipedia.org - 可插拔的外观和感觉
- Java2s.com - 外观和感觉
Related topics :
相关话题 :
回答by Mikle Garin
You can try L&F which i am developing - WebLaF
It combines three parts required for successful UI development:
你可以试试我正在开发的 L&F - WebLaF
它结合了成功的 UI 开发所需的三个部分:
- Cross-platform re-stylable L&F for Swing applications
- Large set of extended Swing components
- Various utilities and managers
- 用于 Swing 应用程序的跨平台可重新设计的 L&F
- 大量扩展的 Swing 组件
- 各种公用事业和经理
Binaries:https://github.com/mgarin/weblaf/releases
Source:https://github.com/mgarin/weblaf
Licenses:GPLv3and Commercial
二进制文件:https : //github.com/mgarin/weblaf/releases
来源:https : //github.com/mgarin/weblaf
许可证:GPLv3和商业
A few examples showing how some of WebLaF components look like:
一些示例展示了一些 WebLaF 组件的外观:
Main reason why i have started with a totally new L&F is that most of existing L&F lack flexibility - you cannot re-style them in most cases (you can only change a few colors and turn on/off some UI elements in best case) and/or there are only inconvenient ways to do that. Its even worse when it comes to custom/3rd party components styling - they doesn't look similar to other components styled by some specific L&F or even totally different - that makes your application look unprofessional and unpleasant.
我开始使用全新的 L&F 的主要原因是大多数现有的 L&F 缺乏灵活性 - 在大多数情况下您无法重新设置它们的样式(在最好的情况下,您只能更改几种颜色并打开/关闭某些 UI 元素)和/或者只有不方便的方法可以做到这一点。当涉及到自定义/第 3 方组件样式时,情况更糟——它们看起来与由某些特定 L&F 样式化的其他组件不相似,甚至完全不同——这使您的应用程序看起来不专业和令人不快。
My goal is to provide a fully customizable L&F with a pack of additional widely-known and useful components (for example: date chooser, tree table, dockable and document panes and lots of other) and additional helpful managers and utilities, which will reduce the amount of code required to quickly integrate WebLaF into your application and help creating awesome UIs using Swing.
我的目标是提供一个完全可定制的 L&F,其中包含一组额外的广为人知和有用的组件(例如:日期选择器、树表、可停靠和文档窗格等)以及额外的有用管理器和实用程序,这将减少将 WebLaF 快速集成到您的应用程序中并帮助使用 Swing 创建出色的 UI 所需的代码量。
回答by diegeelvis_SA
You can also use JTattoo (http://www.jtattoo.net/), it has a couple of cool themes that can be used.
你也可以使用 JTattoo ( http://www.jtattoo.net/),它有几个很酷的主题可以使用。
Just download the jar and import it into your classpath, or add it as a maven dependency:
只需下载 jar 并将其导入您的类路径,或将其添加为 maven 依赖项:
<dependency>
<groupId>com.jtattoo</groupId>
<artifactId>JTattoo</artifactId>
<version>1.6.11</version>
</dependency>
Here is a list of some of the cool themes they have available:
以下是他们提供的一些很酷的主题列表:
- com.jtattoo.plaf.acryl.AcrylLookAndFeel
- com.jtattoo.plaf.aero.AeroLookAndFeel
- com.jtattoo.plaf.aluminium.AluminiumLookAndFeel
- com.jtattoo.plaf.bernstein.BernsteinLookAndFeel
- com.jtattoo.plaf.fast.FastLookAndFeel
- com.jtattoo.plaf.graphite.GraphiteLookAndFeel
- com.jtattoo.plaf.hifi.HiFiLookAndFeel
- com.jtattoo.plaf.luna.LunaLookAndFeel
- com.jtattoo.plaf.mcwin.McWinLookAndFeel
- com.jtattoo.plaf.mint.MintLookAndFeel
- com.jtattoo.plaf.ntheitroade.NtheitroadeLookAndFeel
- com.jtattoo.plaf.smart.SmartLookAndFeel
- com.jtattoo.plaf.texture.TextureLookAndFeel
- com.jtattoo.plaf.custom.flx.FLXLookAndFeel
- com.jtattoo.plaf.acryl.AcrylLookAndFeel
- com.jtattoo.plaf.aero.AeroLookAndFeel
- com.jtattoo.plaf.aluminium.AluminiumLookAndFeel
- com.jtattoo.plaf.bernstein.BernsteinLookAndFeel
- com.jtattoo.plaf.fast.FastLookAndFeel
- com.jtattoo.plaf.graphite.GraphiteLookAndFeel
- com.jtattoo.plaf.hifi.HiFiLookAndFeel
- com.jtattoo.plaf.luna.LunaLookAndFeel
- com.jtattoo.plaf.mcwin.McWinLookAndFeel
- com.jtattoo.plaf.mint.MintLookAndFeel
- com.jtattoo.plaf.ntheitroade.NtheitroadeLookAndFeel
- com.jtattoo.plaf.smart.SmartLookAndFeel
- com.jtattoo.plaf.texture.TextureLookAndFeel
- com.jtattoo.plaf.custom.flx.FLXLookAndFeel
Regards
问候
回答by TheArchon
Heres the code that creates a Dialog which allows the user of your application to change the Look And Feel based on the user'ssystems. Alternatively, if you can store the wanted Look And Feel's on your application, then they could be "portable", which is the desired result.
下面是创建对话框的代码,它允许应用程序的用户根据用户的系统更改外观。或者,如果您可以将所需的外观和感觉存储在您的应用程序中,那么它们可以是“可移植的”,这就是所需的结果。
public void changeLookAndFeel() {
List<String> lookAndFeelsDisplay = new ArrayList<>();
List<String> lookAndFeelsRealNames = new ArrayList<>();
for (LookAndFeelInfo each : UIManager.getInstalledLookAndFeels()) {
lookAndFeelsDisplay.add(each.getName());
lookAndFeelsRealNames.add(each.getClassName());
}
String changeLook = (String) JOptionPane.showInputDialog(this, "Choose Look and Feel Here:", "Select Look and Feel", JOptionPane.QUESTION_MESSAGE, null, lookAndFeelsDisplay.toArray(), null);
if (changeLook != null) {
for (int i = 0; i < lookAndFeelsDisplay.size(); i++) {
if (changeLook.equals(lookAndFeelsDisplay.get(i))) {
try {
UIManager.setLookAndFeel(lookAndFeelsRealNames.get(i));
break;
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
err.println(ex);
ex.printStackTrace(System.err);
}
}
}
}
}