Is Swing Still in Use Today? [closed]

2019-01-25 02:35发布

Is Java Swing still in use? is the most recent post I found, and it is 4 years old (now 8 years old), so...

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.

(I am not asking about a Swing-AWT comparison...just whether or not Swing is obsolete in the workforce.)

3条回答
做自己的国王
2楼-- · 2019-01-25 02:51

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.

查看更多
狗以群分
3楼-- · 2019-01-25 02:56

Majority of existing GUI java codebases are Swing and likely will stay that way until the codebase rots and nobody maintains it anymore.

Majority of new GUI 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.

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).

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.

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.

查看更多
Lonely孤独者°
4楼-- · 2019-01-25 03:04

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).

查看更多
登录 后发表回答