Java 现在还在使用 Swing 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24442672/
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 Swing Still in Use Today?
提问by Evorlor
Is Java Swing still in use?is the most recent post I found, and it is 4 years old (now 9 years old), so...
Java Swing 还在使用吗?是我发现的最新帖子,它已经 4 岁了(现在 9 岁了),所以......
Is Swing used at all in a professional environment? I am a student, and wondering if it is worth learning, or if its day has passed.
Swing 是否在专业环境中使用过?我是一名学生,想知道它是否值得学习,或者它的时代是否已经过去。
(I am not asking about a Swing-AWT comparison...just whether or not Swing is obsolete in the workforce.)
(我不是在问 Swing-AWT 的比较……只是 Swing 在劳动力中是否已经过时。)
采纳答案by SnakeDoc
Majority of existing GUI java codebases are Swing
and likely will stay that way until the codebase rots and nobody maintains it anymore.
大多数现有的 GUI Java 代码库Swing
可能会一直保持这种状态,直到代码库腐烂并且不再有人维护它。
Majority of newGUI java codebases are using JavaFX
, which is the Swing
replacement in Java8
and is part of the standard java library
now. It allows for CSS
skinning, HTML5
elements, and also has a very nice FXML
(a dialect of XML/HTML) which allows non-programmers to "get in there" and work on the GUI layout, etc. It also has SceneBuilder
which is a free/standard GUI drag-n-drop
builder which auto-generates FXML
for your program.
大多数新的GUI Java 代码库都在使用JavaFX
,这是现在的Swing
替代品Java8
和一部分standard java library
。它允许CSS
皮肤、HTML5
元素,并且还有一个非常好的FXML
(XML/HTML 方言),它允许非程序员“进入那里”并在 GUI 布局上工作等。它还有SceneBuilder
一个免费/标准的为您的程序drag-n-drop
自动生成的GUI构建器FXML
。
I kid not when I say FXML
can replace 3,000 lines of extended JFrame class
code for a Swing
GUI, with 50 lines of FXML
. (recent project I helped migrate).
我的孩子不是我说的FXML
可替代3000行extended JFrame class
代码的Swing
图形用户界面,用50行FXML
。(我最近帮助迁移的项目)。
Swing
is still used heavily, and will continue to be for a long while -- after all, it was the only choice for Java for a loooong time. JavaFX
, however, is refreshingly nice, and very-much-so worth learning.
Swing
仍在大量使用,并将继续使用很长一段时间——毕竟,它是 Java 很长一段时间的唯一选择。JavaFX
然而,令人耳目一新,非常值得学习。
As an aside -- Swing builds ontop of AWT - AWT has a lot of problems, most of which are marked as "wont-fix" by the java project (OpenJDK/Oracle). Swing was built to replace/fix AWT, however sometimes you will marry AWT objects into your Swing application. Heck, you will sometimes marry Swing objects into your JavaFX application. I would not bother with learning AWT, if you learn Swing, you are learning AWT for the most part. The largest difference with Swing vs AWT is Swing components start with the letter J
. EX: JFrame
vs Frame
, etc.
顺便说一句——Swing 构建在 AWT 之上——AWT 有很多问题,其中大部分被 java 项目(OpenJDK/Oracle)标记为“不会修复”。Swing 旨在替换/修复 AWT,但是有时您会将 AWT 对象结合到您的 Swing 应用程序中。哎呀,您有时会将 Swing 对象结合到您的 JavaFX 应用程序中。我不会费心学习 AWT,如果你学习 Swing,你在很大程度上是在学习 AWT。Swing 与 AWT 的最大区别在于 Swing 组件以字母 开头J
。例如:JFrame
vsFrame
等。
回答by hanetzer
Well, Intellij IDEA uses Swing for its UI, so I would not say that it is obsolete. Granted, I really think it could use a huge overhaul (read: something not full of spaghetti code).
好吧,Intellij IDEA 使用 Swing 作为其 UI,所以我不会说它已经过时了。当然,我真的认为它可以进行大修(阅读:一些不是意大利面条式的代码)。
回答by TheMonkWhoSoldHisCode
Absolutely yes. Legacy swing applications are still supported and enhanced. There is no alternative for that. And if you are making applications like IDE's, SWING is still preferred. New application will of course have web-interfaces , but that really depends on the nature of the application. No generic rules.
绝对没错。仍然支持和增强旧的 Swing 应用程序。对此别无选择。如果您正在制作类似 IDE 的应用程序,SWING 仍然是首选。新应用程序当然会有 web-interfaces ,但这实际上取决于应用程序的性质。没有通用规则。