有没有基于扁平化设计理念的 Java 外观?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25856139/
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
Is there a java look and feel based on the flat design concept?
提问by Cláudio
I have 5 java systems for engineering whose UI were developed using Swing.
我有 5 个用于工程的 Java 系统,其 UI 是使用 Swing 开发的。
We started the development of these systems about 10 years ago and they have about 300K lines of code each. All these systems are in production environment.
我们大约在 10 年前开始开发这些系统,每个系统大约有 30 万行代码。所有这些系统都在生产环境中。
One question that bother us about the UI of these systems is that they look old when compared with large available UIs of cell phones, tablets and web sites.
困扰我们这些系统 UI 的一个问题是,与手机、平板电脑和网站的大量可用 UI 相比,它们看起来很旧。
What do cell phones, tablets and web sites UI have in common ? Their look is based on the flat design concept.
手机、平板电脑和网站 UI 有什么共同点?他们的外观基于平面设计理念。
So, we′re starting a research to find low cost alternatives to give to our systems a modern look oriented to flat design.
因此,我们开始研究寻找低成本的替代方案,为我们的系统提供面向平面设计的现代外观。
The first option we thought was to search a java L&F that is implemented based in the flat design concept. But We did not find one.
我们想到的第一个选择是搜索基于平面设计概念实现的 java L&F。但是我们没有找到。
Does anyone knows if there is a java look and feel based, specifically, on the flat design concept ?
有谁知道是否有基于平面设计概念的 Java 外观和感觉?
Best regards, Cláudio.
最好的问候,克劳迪奥。
采纳答案by jefflunt
There isn't a pre-built one, and UIs in Swing are...well...one of the most painful experiences in development I've ever had. UI is so inherently platform-specific that cross-platform UIs are a pipe dream for any semi-complex UI. The only place it works is if your UI is basically a menu bar and a surface onto which you draw your own UI.
没有预先构建的 UI,Swing 中的 UI 是……嗯……这是我曾经拥有的最痛苦的开发经历之一。UI 本质上是特定于平台的,因此跨平台 UI 是任何半复杂 UI 的梦想。它唯一有效的地方是,如果您的 UI 基本上是一个菜单栏和一个您可以在其上绘制自己的 UI 的表面。
That said, I think long-term you're probably looking into custom UI and widget work on some level, and though that would be a lot of custom UI tool work, the tradeoff is that at least you would control the UI from that point forward, could keep it up-to-date as you go along, and you wouldn't have to worry as much about what Java decides is good UI design.
也就是说,我认为从长远来看,您可能会在某种程度上研究自定义 UI 和小部件的工作,尽管这将是很多自定义 UI 工具的工作,但权衡是至少您可以从那时起控制 UI向前,可以在您进行过程中保持最新状态,并且您不必担心 Java 认为什么是好的 UI 设计。
Some possible options, none of which are going to be without major pain:
一些可能的选择,其中没有一个不会没有大的痛苦:
- Choose one of the two built-in L&F options, or set it to be the platform default(your app looks like the native platform), though you will have to debug the app on every platform separately to make sure the UI works consistently. At least with this option, if you set it to use the platform default, the app will look approximately like a native app on whatever OS it's on.
- Look into SWT- probably not worth it in the long run - you're just trading one set of less-than-idea situations for another, I think, but good to at least be educated about your options.
- Style the L&F with CSS- never tried this myself - but maybe worth a look. But personally, I would avoid investing any moretime binding your application to Swing if you can avoid it. It's just one of those atrocious desktop experiences, as you've seen.
- Deliver your app as a web application, which I'm sure is a major re-architecting, and just have users access it through a browser. I realize that this is probably the "nuclear option", and totally unrealistic, but just throwing it out there.
- Suck it up and let your app continue to look like crap. There are worse fates in the world.
- 选择两个内置 L&F 选项之一,或将其设置为平台默认值(您的应用程序看起来像本机平台),但您必须分别在每个平台上调试应用程序以确保 UI 始终如一地工作。至少使用此选项,如果您将其设置为使用平台默认值,则该应用程序在其所在的任何操作系统上看起来都大致类似于本机应用程序。
- 研究 SWT- 从长远来看可能不值得 - 我认为,你只是在用一组不太理想的情况交换另一种情况,但至少对你的选择有所了解是件好事。
- 使用 CSS 为 L&F 设置样式——我自己从未尝试过——但也许值得一看。但就我个人而言,如果可以避免的话,我会避免花费更多时间将您的应用程序绑定到 Swing。正如您所见,这只是糟糕的桌面体验之一。
- 将您的应用程序作为 Web 应用程序交付,我确信这是一次重大的重新架构,并且只需让用户通过浏览器访问它。我意识到这可能是“核选项”,而且完全不现实,但只是将其扔在那里。
- 收起它,让您的应用程序继续看起来像废话。世界上有更糟糕的命运。
回答by dkatzel
A quick way to make an old swing app look new is to change its Look and Feel.
让旧的 Swing 应用程序焕然一新的快速方法是更改其外观和感觉。
The Nimbus look and feel looks OK
Nimbus 的外观和感觉看起来不错
Check out the Oracle Tutorial on Look and Feelto learn how to change it or create your own.
查看有关外观的 Oracle教程,了解如何更改它或创建您自己的教程。
All you have to do to change your look and feel is to add a few lines of code to your app.
要改变您的外观和感觉,您所要做的就是向您的应用程序添加几行代码。
Here's how to change to Nimbus:
以下是更改为 Nimbus 的方法:
try {
//recommended way to set Nimbus LaF because old versions of Java 6
//don't have it included
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.
}