“专业人士”如何在java中制作GUI?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2617287/
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
How do "professionals" make a GUI in java?
提问by Jules Olléon
Thanks for your answers to my previous question about GUI in java. I now wonder what are the solutions chosen by professionals to get a nice GUI, for "real" applications. Do you use swing and JComponents and just change the "look and feel" ? Do you prefer awt or another library ?
感谢您对我之前关于 Java 中 GUI 的问题的回答。我现在想知道专业人士选择什么解决方案来为“真实”应用程序获得漂亮的 GUI。您是否使用 Swing 和 JComponents 而只是更改“外观和感觉”?你更喜欢 awt 还是其他库?
Sorry if that question sounds weird, I'm a student and I don't really know how java is used in the real world...
对不起,如果这个问题听起来很奇怪,我是一名学生,我真的不知道 Java 在现实世界中是如何使用的......
采纳答案by extraneon
In our company we use Swing, as that is supported by the JVM out of the box, but we do use color coded background colors for some panels and buttons.
在我们公司中,我们使用 Swing,因为 JVM 开箱即用地支持它,但我们确实为某些面板和按钮使用了颜色编码的背景颜色。
If we'd use something different, like SWT or Jambiwe'd also have to roll out those frameworks for all platforms, and test those frameworks for all OSses and (supported) java versions. Not nice at all.
如果我们使用不同的东西,比如 SWT 或Jambi,我们还必须为所有平台推出这些框架,并针对所有操作系统和(支持的)java 版本测试这些框架。一点都不好看。
It is however fairly tricky to create a nice responsive application with Swing; so you really need to use SwingWorker and the like. With a bit of experience however you can create a nice application that way.
然而,使用 Swing 创建一个很好的响应式应用程序是相当棘手的。所以你真的需要使用 SwingWorker 之类的。但是,只要有一点经验,您就可以通过这种方式创建一个不错的应用程序。
And even if it isn't the fastest framework to develop in, development time is really small compared to defining the functional requirements of the user interface, and testing and support when the version is released.
即使它不是开发中最快的框架,与定义用户界面的功能需求以及版本发布时的测试和支持相比,开发时间也非常短。
That said, our target is desktops. If you target mobile devices or also need a web frontend your choices may vary.
也就是说,我们的目标是桌面。如果您的目标是移动设备或还需要 Web 前端,您的选择可能会有所不同。
回答by duffymo
I don't believe anyone prefers AWT anymore. Swing supplanted it entirely eleven years ago, building on top of it to correct flaws in the AWT 1.0 design.
我相信没有人更喜欢 AWT 了。Swing 在 11 年前完全取代了它,在它的基础上构建以纠正 AWT 1.0 设计中的缺陷。
Swing isn't the only way that professionals make Java UIs. That works for desktops, but there's also JavaFX now. For the web, UIs are built using HTML, CSS, JavaScript, and JSPs.
Swing 并不是专业人员制作 Java UI 的唯一方法。这适用于桌面,但现在也有 JavaFX。对于 Web,UI 是使用 HTML、CSS、JavaScript 和 JSP 构建的。
回答by Uri
My experience is that most organizations that want to create rich GUIs still use Swing, and manually go through all the annoyances of layout managers, etc.
我的经验是,大多数想要创建丰富 GUI 的组织仍然使用 Swing,并手动处理布局管理器等的所有烦恼。
The use of SWT is fairly limited to organizations that are using the Eclipse RCP as their platform. I'm not sure why it hasn't caught on outside this platform.
SWT 的使用仅限于使用 Eclipse RCP 作为其平台的组织。我不确定为什么它没有在这个平台之外流行起来。
It's sad to admit, but Java Swing GUIs don't generally look good unless you spend a lot of time creating a more native feel for them. Even then, they often lose out on aesthetics to equivalent programs written specifically for Windows and which use Window APIs like WinForms.
不得不承认,Java Swing GUI 通常看起来并不好,除非您花费大量时间为它们创建更原生的感觉。即便如此,与专为 Windows 编写并使用 WinForms 之类的 Window API 的等效程序相比,它们的美观性也经常下降。
回答by Marcus Adams
Macintosh OS X creates their own Java runtime. They give Swing components the same look and feel as native applications.
Macintosh OS X 创建自己的 Java 运行时。它们赋予 Swing 组件与本机应用程序相同的外观和感觉。
I use strictly Swing. I distribute "real" desktop applications via Web Start for both Mac and Windows that interface with the user's smart card reader.
我严格使用 Swing。我通过 Web Start 为 Mac 和 Windows 分发“真正的”桌面应用程序,这些应用程序与用户的智能卡读卡器相连接。
The NetBeans IDE gives you a WYSIWYG way to create your forms. I've tried it out, and it's pretty neat, but we still use Eclipse as our IDE and design the forms in code.
NetBeans IDE 为您提供了一种所见即所得的方式来创建您的表单。我已经试过了,它非常简洁,但我们仍然使用 Eclipse 作为我们的 IDE 并在代码中设计表单。
回答by stacker
The most decent Apps I saw in the last years were build using Eclipse Rich Client Platform
过去几年我看到的最体面的应用程序是使用 Eclipse Rich Client Platform 构建的
Eclipse uses the Standard Widget Toolkit
Eclipse 使用Standard Widget Toolkit
and provides Graphical Editing Framework (GEF)
并提供图形编辑框架 (GEF)
回答by Fabio de Miranda
We typically use Swing becuse it's supported in standard JREs out of the box. Normally we do the initial form design and event hookup in Netbeans and then export it to whatever we wish, Eclipse, for example.
我们通常使用 Swing,因为它在开箱即用的标准 JRE 中得到支持。通常我们在 Netbeans 中进行初始表单设计和事件连接,然后将其导出到我们想要的任何东西,例如 Eclipse。
Netbeans spits out pure Java using standard libraries (plus a jar or two you have to include) so it's no big deal designing the form in Netbeans and later moving on to something else.
Netbeans 使用标准库(加上您必须包含的一两个 jar)输出纯 Java,因此在 Netbeans 中设计表单并随后转向其他内容并没有什么大不了的。
Some people suggested doing form layout by hand using a layout manager. I see that as an option only if you are doing something big and very well budgeted that has to be maintained ad infinitum. Otherwise it's just too time consuming to be worth it.
有些人建议使用布局管理器手动进行表单布局。我认为,只有当您正在做一些必须无限期维护的大型且预算充足的事情时,才可以选择。否则太浪费时间了,不值得。
回答by Zack Angelo
We rely on SWTfor our Java GUIs. Yes, you have to include an external native library, but the look and feel is native, more responsive (although Swing has become much faster in the past few years) and seamless with other apps on the target platform.
我们的 Java GUI依赖于SWT。是的,您必须包含一个外部本机库,但外观和感觉是本机的,响应速度更快(尽管 Swing 在过去几年变得更快)并且与目标平台上的其他应用程序无缝对接。