34

I am planning on making a Java Swing application and was wondering if Swing is still used or if it has been replaced with something else.

Thanks in advance!

Betamoo
  • 14,964
  • 25
  • 75
  • 109
Mark Szymanski
  • 56,590
  • 24
  • 70
  • 87
  • Related: http://stackoverflow.com/questions/407343/where-are-swing-applications-used – Betamoo Jun 08 '10 at 02:27
  • Related: http://stackoverflow.com/questions/408820/what-is-the-difference-between-swing-and-awt – Betamoo Jun 08 '10 at 11:14
  • Related: http://stackoverflow.com/questions/2377467/if-swing-has-more-features-to-design-a-form-then-what-is-the-use-of-awt-in-java – Betamoo Jun 08 '10 at 11:14
  • Related: http://stackoverflow.com/q/24442672/1889720 – Evorlor Apr 17 '16 at 15:58
  • Hi @Mark . Swing is not wo spread but still in use, but maybe you can choose something more update for your application, like [Griffon](http://griffon-framework.org/) or [JavaFX](https://openjfx.io/). – Jonatas Emidio Dec 14 '18 at 21:45

10 Answers10

26

Swing is still in use.... but there is AWT!!

AWT:

Pros:

  • Speed: use of native peers speeds component performance.
  • Look and Feel: AWT components more closely reflect the look and feel of the OS they run on.

Cons:

  • Portability: use of native peers creates platform specific limitations. Some components may not function at all on some platforms.
  • Third Party Development: the majority of component makers, including Borland and Sun, base new component development on Swing components. There is a much smaller set of AWT components available, thus placing the burden on the programmer to create his or her own AWT-based components.
  • Features: AWT components do not support features like icons and tool-tips.




Swing:

Pros:

  • Portability: Pure Java design provides for fewer platform specific limitations.
  • Behavior: Pure Java design allows for a greater range of behavior for Swing components since they are not limited by the native peers that AWT uses.
  • Features: Swing supports a wider range of features like icons and pop-up tool-tips for components.
  • Vendor Support: Swing development is more active. Sun puts much more energy into making Swing robust.
  • Look and Feel: The pluggable look and feel lets you design a single set of GUI components that can automatically have the look and feel of any OS platform (Microsoft Windows, Solaris, Macintosh, etc.). It also makes it easier to make global changes to your Java programs that provide greater accessibility (like picking a hi-contrast color scheme or changing all the fonts in all dialogs, etc.).

Cons:

  • Performance: Swing components are generally slower and buggier than AWT, due to both the fact that they are pure Java and to video issues on various platforms. Since Swing components handle their own painting (rather than using native API's like DirectX on Windows) you may run into graphical glitches.
  • Look and Feel: Even when Swing components are set to use the look and feel of the OS they are run on, they may not look like their native counterparts.



More Reading..

Betamoo
  • 14,964
  • 25
  • 75
  • 109
  • 11
    "Applet Portability: most Web browsers support AWT classes so AWT applets can run without the Java plugin." This is patently false. – Paul Fisher Jun 08 '10 at 02:06
  • 6
    ugh? I guess this is 1990s and you are still using Netscape 4.0, right? – J-16 SDiZ Jun 08 '10 at 02:11
  • 4
    I wouldn't recommend AWT, it gets very little love these days (other than the bits that are needed for Swing). Better to use SWT if you want to go down the native path. – CurtainDog Jun 08 '10 at 03:54
  • "Most Web browsers do not include the Swing classes, so the Java plugin must be used." — What? The Swing classes are part of the JRE, not the browser. I don't recall this being a problem in 2003. – detly Jun 08 '10 at 05:53
  • 1
    “they *may* not look like their native counterparts” – that one made me giggle. At least on Windows I have yet to see a single control (apart from JLabel maybe) that looks and feels like its native counterpart with the “native” LAF :-) – Joey Jun 19 '10 at 10:29
  • "rather than using native API's like DirectX on Windows": false, Swing uses Java2D, which may use DirectX when supported. "Swing components are generally buggier than AWT": this is false as well. – ignis Oct 27 '12 at 17:37
  • You didn't mention that AWT's event model is a bit of an inconsistent mess. At least that's what I remember from using it pre-swing days. – Bill K Jan 19 '17 at 23:18
12

Swing is still there and well supported.

Most of the reasons why people hated swing when it first came out are no longer valid simply because of Moores Law, along with improved JVMs. Swing apps no loger feel jerky and unrepsonsive and an accumulation of minor improvements result in a more professional looking GUI.

Its also worth looking at the "groovy/swing" combination for rapid development and prototyping.

James Anderson
  • 27,109
  • 7
  • 50
  • 78
  • Docs for Swing, on the other hand, are dire to nonexistent. – JUST MY correct OPINION Jun 08 '10 at 04:07
  • Aggree that the docs are lacking somewhat, but, IDE support is pretty good, and, googling usually gets you some decent usage examples. – James Anderson Jun 08 '10 at 05:52
  • 1
    There is a lot of tuning in Swing that cannot be attributed to Moores law. – Thorbjørn Ravn Andersen Jun 08 '10 at 06:21
  • @JMcO For documentation -> http://download-llnw.oracle.com/javase/tutorial/uiswing/ – h3xStream Aug 01 '10 at 00:56
  • 1
    The swing docs are generally pretty good. The javadocs have some pretty In-depth examples for the more complicated aspects. I realize they aren't up to par with other systems that have active demos of each control type on a huge web page, but for implementation what you need to know is there. Groovy/SwingBuilder is amazing but actually is virtually undocumented, I've had to sift through vast piles of garbage to find extensive lists of properties or that some constructs even existed! – Bill K Jan 19 '17 at 23:23
11

Yes. Roughly 1 out of 120 questions on StackOverflow is about Swingenter image description here.

Ivan Nikitin
  • 3,578
  • 27
  • 39
11

We still use it. Not everything is a web app, so far there have been some tentative replacements (such as SWT, which eclipse is written in)
SWT has a native layer that wraps the underlying calls to the native windowing layer. It only works for a limited set of platforms and of course requires some third party shared libraries. I would venture to say that there are far fewer SWT apps than Swing apps.

Romain Hippeau
  • 24,113
  • 5
  • 60
  • 79
5

Yes, it still is in use. The library is still part of the JRE, and will probably be that way for the future. There are other options though. For instance, you may want to look at JavaFX if you need a rich UI; or using SWT in your application. Maybe you want some kind of 3D effects, and you need to look into a 3D engine like jpct or the jmonkeyengine. Java has progressed somewhat since the software Swing world.

JavaMan
  • 53
  • 5
2

Although swing is still in use, I would rather chose Eclipse RCP as a platform for desktop applications, since it also provides a huge amount of plugins.

stacker
  • 68,052
  • 28
  • 140
  • 210
  • 1
    Eclipse RCP uses Eclipse's own SWT, which means you need the native SWT libraries. You can also build on the NetBeans Platform, which is built on Swing: http://platform.netbeans.org/ – Jesper Jun 08 '10 at 11:14
1

Yes, it's still in use. Takes while to get used to but once you have it, it's a pretty nice framework for writing applications. Have a look at Webstart for deploying your application. Also a bit of a clunker to start with but really handy when you're comfortable

Jamie McIlroy
  • 459
  • 2
  • 8
  • 19
1

For desktop programs, yes, Swing is heavily in use. However there are many alternatives because alot of people think that Swing is heavily verbose and hard to work with. JavaFX is worth taking a look at

TheLQ
  • 14,830
  • 14
  • 69
  • 107
1

You can still use Java Swing, though I'd recommend using JavaFX. Designing UIs is easier as the SceneBuilder helps you do just that. It is also newer, so longer support and development. The advantage of Swing is that it has been out for quite a long time, so you'll find more tutorials and help for Swing, but JavaFX is catching up. If you'd like to learn JavaFX, I recommend following the tutorial series by thenewboston on YouTube.

Unterbelichtet
  • 628
  • 2
  • 7
  • 18
0

Swing is still the preferred way to build heavy-weight, e.g. "Desktop" applications, in Java. If your code is running in a web browser, you will likely use other things. But for freestanding desktop apps, it is quite excellent and in wide use.

Joe Zitzelberger
  • 4,238
  • 2
  • 28
  • 42