I am reading Head First JAVA and there comes a chapter on GUI which is using Swing.
I heard a lot that swing are useless these days so I want to know that should I learn using Swing or not.
Will it be beneficial for me further.
A lot of people will say a lot of things, Swing is used a lot and if you are going to use a GUI then it will either be Swing/AWT(older) or the new JavaFX.. It depends what you are trying to accomplish, but most everything uses a GUI and Swing is what you will most likely be using until JavaFX takes over(Which it is starting to since 2.0 has made a huge movement) and Oracle says that are stopping support on Swing(I believe so).
AFAIK Oracle isn't stopping support for Swing. Swing has been declared to be in maintenance mode, which means bi new API, and the only changes to the code will be bug fixes. Not that Oracle or Sun before them have a great track record in fixing Swing bugs; there are some unresolved bugs that were reported more than 10 years ago.
There are no new questions, but there may be new answers.
Yeah im not really sure there was a post on here about it and there was some conference where this was discussed. I would assume bug fixes would be continued, but yes no new api and fx is what they are focussed on. Fx is really awesome though cannot wait to see its future.
Claude Moore wrote:Just a question: it seems to me - after reading these posts- that FX will superseed swing. Did I understand well ?
Or is it a hasty conclusion?
To my knowledge it's kind of like Swing superseding AWT(I believe). AWT has the old school look and Swing has the more modern look/feel. FX originally was a scripting language to my knowledge, but now it's becoming part of the Java Platform itself. Just by looking at the FX demo example I believe called (Encore) it shows extremely amazing ability and 3D capabilities. It's engine is much faster, and I hear stuff like file chooser calls are much faster. Overall I think FX will take over from Swing, but Swing will still be used, just like AWT is still available for use. Now there is a lot of talk(especially on this forum) about if people should goto FX right now or still use Swing. Swing is still the big boy IMO, and FX from 2.0(now 2.0.3) has shown BIG changes. IMO FX will come out on top, but when that is I'm not sure. People still say you should use Swing, but switching to FX now might be a good idea... I also hear that Swing/FX cannot be used together, but I'm not 100% sure on that, and I've only heard people say that, without any real evidence.
Coding for a mixed FX/Swing application is cumbersome, though, because of having to take care of thread safety in two separate GUI threads: the EDT and the Application thread. That can leads to the code being peppered with invokeLater/runLater. As a small example, here's a SSCCE I posted on another forum to illustrate interaction of Swing and FX components: http://www.java-forums.org/awt-swing/55491-sup-tag-doesnt-work-properly-2.html#post266518
I had a feeling that there was another version ahead of 2.0.3, thanks Darryl. I'm glad that you can mix the 2, but yes I can understand the frustration of having to watch for thread safety and all that other bs .
and yes FX is still young, and they are still working on improvements, etc, but with Java 8/9 coming we will see major fixes for sure.
Also in response to the original question: learning Swing will force you to learn a number of programming techniques which would apply directly to Java FX programming. So even if you think that FX will take over from Swing at some time in the future, it's still a good idea to learn Swing.