Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Is Java Swing really used for constructing real-world software?

I'm taking an introductory course in Java, but nothing more than drawing some shapes, lines & basic tables.

share|improve this question

migrated from stackoverflow.com Oct 4 '11 at 1:24

This question came from our site for professional and enthusiast programmers.

1  
Google it my friend and you will see many examples –  Romain Hippeau Oct 4 '11 at 0:36
    
Well, technically it's not a programming problem. Its a question about a specific technology (Swing), not a language. –  Daryl Teo Oct 4 '11 at 0:36
    
Yes Swing is used. IBM's SWT is also a popular alternative. –  CoolBeans Oct 4 '11 at 0:43
2  
Whether you skip it should depend mostly on what your instructor tells you to do, not based on our ruminations. –  Hovercraft Full Of Eels Oct 4 '11 at 1:02
    
Have a little fun with it. If you take what you've learned in the assignment and expand upon it, you could probably make it into a final project of some sort. That sure beats the "LET'S PLAY BATTLESHIP _,_" variety ;) –  jonsca Oct 4 '11 at 2:36
show 1 more comment

6 Answers

Swing is actually quite useful in real world software applications.

In another post ( http://stackoverflow.com/questions/7494190/purpose-of-jpanel/7494542#7494542 ) , I liken Swing to HTML in terms of usage, as it really does make resizable application windows easy in a way that's quite striking when compared with its predecessor AWT.

That's not to say that Swing is the end all framework, but as a basic framework built into the JVM (not requiring external libraries) it's definitely very useful, and using it instead of a library like SWT will allow you to keep your applet/application very small.

One of my applications does animation into a Swing JPanel, and takes advantage of the resizing messages to change the size of the content automatically to match the size of the panel. Once you get the hang of it, it's really quite the pleasure to deal with, but until then, it can be a royal pain, especially the thread requirements to run things on the dispatcher thread for anything that updates the screen.

share|improve this answer
add comment

Yes, Swing is pretty widely used.

Its real strength is for "write once run anywhere" cross-platform application development, where it's one of the few ways you can reliably get a consistent user interface on a broad range of platforms (the other good alternative is a web application with JavaScript/HTML).

Because the components are "lightweight" i.e. rendered directly by the Swing libraries, you get the same look and feel regardless of what platform is being run on. This is sometimes considered a disadvantage (because it doesn't look "native" on many platforms) but can also be an advantage (you can standardise your look and feel across platforms, you can also customise your look and feel in any way you like).

Although I don't have any starts to back this up, my impression is that Swing is used more often in corporate / enterprise environments (where portability and maintainability are important) rather than consumer applications (where a native look and feel is expected).

Personally I think Swing is a pretty decent GUI framework, it's generally easy to use and gives you a lot of control if you need it.

You can even do some quite cool / impressive things with the pluggable custom look and feels - for example the Napkin look and feel makes your app look like it was scribbled on a Napkin if that's the look you are going for......

share|improve this answer
add comment

Is Java Swing really used for constructing real-world software?

I can't see any reason why not use that,

1) reall dis-advantages my view

  • poor support for multimedia

  • reduced support for Html & css <= Html 3.2

  • very old Look and Feel, including Nimbus (sometimes are so tricky change its default)

  • sometimes is so tricky overrive some of methods, because all AWT & Swing J/Component are based on nested or inherits methods throught whole Java API

  • use premature Arrays's types (bases build in the years 2002-2004, and in this time Java didn't implements that at all...)

2) real advantages my view

  • to old but non-buggy and stable "framework"

  • Swing & ATW is as puzzle, in almost cases is everything there possible

  • by usage of Custom Look and Feel is possible to create nice GUI

  • all Events to the GUI are done only on EDT, I take single threading in Swing (in all cases) as advantage

3) there were lots of promisses about whatever, there were lots of official Sun's supported Frameworks SWT, Java Desktop Aplication, SwingX end with JavaFx, something hapends because new Java owner ..., really nothing hapends, my view is same about Java7. Sun's injections to the SWT, Java Desktop Aplication, SwingX ends and Java Desktop Aplication, SwingX died, JavaFx looks like as historical Atari ...

4) there are another Custom Free & non-Free Frameworks, but all is based on ATW and Swing methods

5) notice: most important everything (be sure about that) is based on

  • use proper LayoutManager properly

  • never to set Size, Font, FontSize and Color(for Color is better to look for Custom Look and Feel)

  • don't to try to reinvent the wheel :-),

share|improve this answer
add comment

I'll add a slight counter point to the previous answers and state that whilst Swing is certainly useful (and that Oracle isn't going to all of a sudden drop it) it does look like Oracle will be pushing forward with JavaFX 2.0+ as their rich client of choice. My guess is that Swing is not seen as a future technology. and you may not want to spend vast amounts of your time learning it.

share|improve this answer
4  
JavaFX is more of a replacement/alternative to Swing/AWT applets than applications... Nice for your RIA, but not your standalone application or client/server components. –  jwenting Oct 4 '11 at 7:09
add comment

Many companies are using a combination of Swing and a forms designer which makes layouting a lot easier than coding the GUI by hand. The JFormsDesigner is a good example of one of those tools.

share|improve this answer
add comment

Before "Web 2.0" Swing was defacto standard for building browser based rich client. Today everybody switched to ajax webapps since.

Swing is still quite popular for portable desktop applications, however Python is taking over that market a bit.

I used to work as a developer for a big swing-based application. You need to consider pros and cons. There used to be a lot of pros for swing. Today is not as much but still you have powerful, portable and stable API.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.