40

Is Java Swing still in use? is the most recent post I found, and it is 4 years old (now 12 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.)

5
  • 10
    Yes, Swing has a large following, has a proven track record and a wide availability of 3rd party support. The future is a difficult thing to predict and is always fluent. There are still some companies using AWT :P. Is it worth learning. That will depend on your career choices, but having a good understanding of MVC and things like, the observer pattern and produce consumer patterns would probably hold you in greater stead Commented Jun 27, 2014 at 1:31
  • 7
    There's a good bit of opinion involved in what to learn, but the question is pretty clearly asking whether Swing is widely used. That's a question that can be answered reasonably objectively and helpfully. Commented Jun 27, 2014 at 1:57
  • 5
    Good question. Too bad it's been closed. "We are using Swing for X"-type answers would have been extremely helpful. Commented Mar 14, 2016 at 14:30
  • 4
    How can this be "primarily opinion-based". Usage is a measurable fact, that can be backed with figures. Commented Mar 2, 2017 at 14:46
  • 2
    I am maintaining very large application in swing still. Its easy, robust, fast and very handy. I have created some framework for my own and finally i am continuing... Commented Mar 24, 2019 at 23:16

3 Answers 3

66

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.

3
  • 4
    Is this answer still valid, 5 years later?
    – Evorlor
    Commented Oct 8, 2019 at 13:51
  • 9
    @Evorlor Yes. If not even more-so. JavaFX has grown a lot, and was spun into it's own project complete with a lot of corporate backing. One should note, however, these days many people may prefer to create a web application instead of a desktop application - JavaFX can help with that too.
    – SnakeDoc
    Commented Oct 8, 2019 at 16:18
  • Adding relevant point - JavaFX is no longer included in the JDK. It is now available as a separate download from openjfx.io. JDK 11 Release Notes, Important Changes, and Information Commented Aug 15 at 17:21
13

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

1
  • 5
    Swing doesn't need to be full of spaghetti code. That's application design. Spring MVC, or even EJB 3.x can be just as full of spaghetti code. I've seen beautiful projects made with swing, both on the outside as on the inside. Everything the JS world is trying to implement now in their Single-page applications has been done decades ago with Swing. It's very object-oriented, and reactive to boot.
    – dieterh
    Commented Jun 26, 2017 at 11:33
11

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.

4
  • 1
    I would think that Eclipse RCP (SWT) or even Netbeans Platform (Swing) would be a better option to make an IDE over Swing alone.
    – Mister
    Commented Jun 27, 2014 at 2:14
  • @Mister it would depend on the project, since using any 3rd party Windowing Toolkit (such as SWT) introduces additional dependencies, bloat, and possible complications, etc.
    – SnakeDoc
    Commented Jun 27, 2014 at 14:49
  • @SnakeDoc What possible complications? The netbeans and eclipse platforms have been proved stable and lots of applications are based on them
    – rpax
    Commented Dec 12, 2015 at 13:32
  • @rpax each windowing toolkit has it's own problems the developer must account for. most people will learn one really well.
    – SnakeDoc
    Commented Dec 14, 2015 at 15:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.