whether reading swing is worth it? - java

i planning to read swing concept, if it is worth reading ,please suggest some study material

There are too many GUI toolkits for Java since the AWT debacle. Even Swing has been seriously downplayed by critics, they have thier reasons though. But there are still lot of advantages of playing with Swing:
Inherently Swing is slightly tough to use. So once you have done through swing, you may probably get through any other technology smoothly.
Swing has a good design: Ok not from usability point of view, but still there is something really beautiful about Swing's design and approach to GUI programming. You will understand that when I tell you how many different toolkits we have integerated along with Swing, we couldnt do the same for other GUI toolkits.
Well I can assure that using Swing will improve your code-digging abilities. People who have suffered Swing would tell you :)
Note: But all this only applies, if
you have enough time and a spare job
:)

Its good to know, won't hurt.
As a Java programmer you might need to make small utility applications from time to time, so why not make them a good GUI.
Aside from that, i would suggest a graphical IDE, like Netbeans. You can use the Swing components and dig in the "auto-generated" code when you need to.

From my experiences with Swing, I think that it really depends on what you are planning on using it for. Swing was the first tool I used for designing GUI applications. I felt it was easy to use, and there is very good documentation and tutorials all over the internet on Swing. After a certain period of time, I came to realize the limitations in Swing and made a personal conclusion that Swing was a great tool for learning, and for developing small desktop applications.
Unfortunately these characteristics can only take you so far. I personally feel that Swing is limiting in that it is not a very powerful tool beyond windows and text boxes. If you are looking at doing something with the absolute most basic need of these features, then yes you would use Swing. On the other hand, if you plan on creating Powerful, professional applications, then swing might not be the tool for you to spend your time mastering. There are other tools out there that allow you to go beyond the limitations of Swing in regards functionality and efficiency.
So once again, it really depends what level you currently consider yourself, as well as what you plan on doing in the future. For everyday, "play" coding, Swing is great, but if you plan on doing anything more, then research other tools first.

Swing is necessary to learn if you wish to make desktop applications with Java. Also, it can't hurt to learn about it, as that many of the techniques used in Swing are found in Design Patterns and other GUI toolkits.

Related

Regarding bulding gui and widgets in java [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am a complete beginner in java. Although i have studied a lot of literature on the language (well sort of), this is my first real project.
I was basically planning to make a simple clock widget and later plan to build Gui s. Until now, i had learnt in swing. But then i found on this site that Swing is kinda outdated
( ref : Java GUI frameworks. What to choose? Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot?).
What i needed was some good libraries in java to assist me in this process ( the clock widget and subsequently more complex gui). So i thought of getting libraries from jgoodies, the free ones.
And now i am utterly confused and messed up on what to do and dont understand anything. And of course i dont need books in design patterns etc etc. Just java references and some tutorials on gui using java and jgoodies to get me started. And i cant find them anywhere.
So please point me in right direction.
Reading background (Head First java, java the complete ref and data structures and algo)
(Suggest others if not sufficient)
AWT has effectively been replaced by Swing.
SWT is a different framework, which provides greater native interaction with the OS
JavaFX is the new player on the block, while some consider it a replacement for Swing, it's primary intention was to display Flash or act as an alternative to it.
SwingX and JGoodies are Swing based libraries.
Swing and SWT have begin around for quite some time, some might consider them to be "old", but what it does mean is there is a body of knowledge surrounding the frameworks, as well as a number libraries designed to support and extend them
JavaFX is new player on the market and has yet to build the same knowledge and support base.
If I was you. I would pay attention to Swing (personally) as it is going to provide you with the best ground base of experienced developers and support to help you on your way.
Once you become more comfortable, you could explore SWT, JavaFX and other toolkits and frameworks.
I would start with Creating a GUI with Swing, Performing Custom Painting and 2D Graphics.
My (personally) feeling is to build an understanding of the base library, try and learn it's strengths and weakness. This will help you understand when to use such libraries as SwingX and JGoodies - IMHO
What i needed was some good libraries in java to assist me in this process ( the clock widget and subsequently more complex gui). So i thought of getting libraries from jgoodies, the free ones.
Probably you don't need libraries as much as you think you do. Learn stuff from first principles and you will learn it better.
All the major Java GUI frameworks are quite high level and functional already. When you are first starting out, I think you should skip 3rd party libraries and see how far you get with what is provided in the base JRE and the framework of your choice. There is more than enough to learn with just the basic frameworks, the java language and the JRE. If you try to add in other frameworks too early, you will end up overloaded, confused and less productive. Plus the increased abstraction of the libraries may prevent you from learning some of the important underlying principles well enough.
Once you get a bit more experience in building things, then you will have a much better idea where the gaps in the frameworks are for your application and you can add in 3rd party libraries at that time.
planning to make a simple clock widget
If you get stuck, here is code for a JavaFX clock: How to draw a clock with JavaFX 2? or a similar implementation in Swing.
Note that creating a clock is quite a bit different than creating a traditional form based GUI that makes use of a library of predefined controls - but any of the major Java GUI frameworks can handle both tasks.
Don't make a clock your first GUI programming task, do something easier. Then try to create a clock later.
using swing for precise layout is really a difficult job
There are interactive graphical layout managers for Swing and other frameworks (e.g. the excellent SceneBuilder for JavaFX) which make this easier.
However, when first starting, it's probably worth hand coding stuff rather than letting a tool manage the layout for you (for example when learning JavaFX, stick with just the Java API and don't use FXML until you are completely comfortable with the Java API). You will learn the ins and outs of layout management and other things better that way. Sure you will make some mistakes and there will be a bit of frustration, but things will become clear in time with some persistence. And you may eventually end up deciding that you prefer hand-coding rather than using a graphical tool anyway.
The tricky part is usually creating quality, dynamically resizable GUIs that look good at different resolutions and window sizes - and that is generally tricky for beginners no matter what GUI toolkit is used.
The layout managers in JavaFX are very similar to the basic layout managers in Swing - so layout-wise there is little difference between the two frameworks.
The retained mode Scene Graph in JavaFX may be a bit easier to work with than the direct mode painting of Swing, but I guess that is not quite layout related.
Introspection tools, such as ScenicView for JavaFX, ease debugging layouts at runtime. Think of things like ScenicView as something similar to Firebug for HTML (e.g. your essential layout debugging companion).
And now i am utterly confused and messed up on what to do and dont understand anything.
You understand more than you think you do or you wouldn't have known enough to ask this question.
What you should do (IMO) is just pick a Java GUI framework (any framework - they are all passable), pick a decent starting task (something that seems mind-numbingly simple - even simpler than a clock) and start coding. Make everything task related; very small tasks with clear end-goals. Write a decent amount of code and always go back and revise your code and it's output to try to make it the very best it can be - don't settle for good enough.
Try painting rainbows and happy faces - when you code that up and see it on the screen, you will feel good about yourself :-)
If you need a refresher on the Java language, follow the Oracle Learning the Java Language trail. That trail is the way I learnt Java many years ago. It has been maintained over the years so that it is still a great resource and useful today.
If you choose Swing, follow the starting links from MadProgrammer.
If you choose JavaFX, follow the JavaFX tutorials and the Ensemble sample app but be aware that some of the JavaFX tutorials are targeted to more experienced programmers.

JavaFX and Swing --- finding a middle ground?

I am so-so with Swing and just starting to learn JavaFX. I went over a few answers on SO with regards to which one to use and I still can not make up my mind.
Is it possible to get the best of both the worlds ??
Like, use JavaFX with I want to give some visually appealing graphics and add some Swing to JavaFX when I want to ?
You can use JavaFX in Swing applications via the JFXPanel control. See the SwingInterOp sample. You can also utilize JavaFX from inside sophisticated Swing based platforms such as NetBeans RCP.
A current limitation of JavaFX/Swing integration is that you can embed JavaFX components in a Swing application, but not Swing components in a JavaFX application. RT-12100 Swing in JavaFX embedding support is currently scheduled for Java 8.
If you have a green field new application to develop, I'd advise choosing one technology or the other and sticking with that or at least keeping the integration points localized and few and far between. Both frameworks are large and take time to learn, plus you will avoid any integration headaches such as needing to take care that Swing processing is done on the Swing Event Dispatch thread and JavaFX processing is done on the JavaFX Application Thread.
JavaFX also integrates with SWT and that integration is currently simpler than the JavaFX/Swing integration (because there is only a single GUI thread to worry about).
Here is a screenshot of JavaFX/Swing interop sample from Oracle:
I went over a few answers on SO with regards to which one to use and I still can not make up my mind.
Rather than doing that, I'd advise picking a small application and implementing it from scratch in Swing and JavaFX and seeing which you prefer. It's time better spent as there is no substitute for hands on experience - then, if you still have questions (hopefully more specific and targeted), come back to StackOverflow to research or ask them.
It depends on your motivation for learning them. If you're looking primarily to boost your CV in the near future and become attractive to businesses, then (for the moment at least) there's many more applications out there written in Swing than JavaFX, purely because the latter is a much newer toolkit.
However, if you're thinking more long term or just want the best tool for the job, personally I find JavaFX to offer more flexibility, be much easier to code in an aesthetically pleasing way, and easier to learn as well (the API behind it is just much nicer.) The only thing against it at the moment is that there's some features that I'd really like to be included, but aren't yet (again, naturally this is what you get by going for the newer toolkit.)
I'd also advise against mixing the two. I'm currently involved in two projects using JavaFX, one entirely JavaFX based and the other a mixture of FX and swing. The latter is much more fiddly to maintain, primarily because of the difference in dispatch threading.
As a previous poster stated, you can use JavaFX in Swing applications now. But since Oracle has declared that JavaFX is the future of the desktop for Java, why not just learn it. I've tried to keep current on both and it's a chore. I'm planning on focusing on JavaFX exclusively in the future -- less chance of confusing myself.
That said, JavaFX still doesn't seem to be a full-fledged member of the JDK, especially if used in conjunction with other languages, like Clojure for example. Depending on the JavaFX version, there are different machinations to go through to pull it into build tools. But that situation is getting better with each release.

Displaying audio signals

We are trying to display the input audio signals already recorded form an electric guitar, using a variety of amplifiers. We are looking for an algorithm to display with Java.
We are currently looking at AWT and Swing libraries and are wondering: which would be better suited to graphic or visually displaying this?
Use Swing rather than AWT for this. Either is capable of doing it, but Swing is more modern and supports components (JTree, JTable..) and functionality (double-buffering built-in, key bindings, PLAFs, support for rich text) that is missing from the AWT APIs.
Another advantage of using Swing is that it seems you are at a stage where you need to ask further questions. Most people who program GUIs using Java SE have never used AWT components, and the rest of us have mostly forgotten how! (There are also many more people who can help with Swing than JavaFX, at this point.)
In AWT you might use a Canvas for drawing the waveform, but in Swing you would use either of the following:
A JPanel (or sometimes a JComponent) where to paint we override paintComponent(Graphics)
A BufferedImage display in a JLabel.
You can see examples of the first technique at DrewTubeish - here is Leftover Wine.
Would you be allowed to use JavaFx? Reason I ask is JavaFx 2.0 has some excellent api's designed specifically for this sort of multimedia task. This is doable with swing or awt for sure but why not be kind to yourself? I don't have time or space to go deeply into it here but I'd recommend either 'Introduction to Javafx 2.0 by Example' or 'Pro JavaFx 2.0' both by Apress. I'd say the second is better, more comprehensive. I believe both have sample code that does pretty much what you just described.
Good luck!!
JFreeChart includes a variety of suitable charts; there's a time domain example here. This KineticModel extends JLabel and implements Icon to display a frequency domain Histogram. Neither requires Swing, but either works better in a Swing context.
I've used AWT, Swing and JavaFX for major projects in Audio, including waveform drawing and editing. Here are my thoughts:
AWT is not being developed or taught. I don't know of any developers who still work with it. I would not use it.
JavaFX is a disaster. Back in 2010 I was working on the largest JavaFX codebase around, and we dropped it for swing. I'm sure it's gotten better, but I haven't yet heard anyone say it can handle major projects. If your project is small, JavaFX may be a good choice, or if you feel strongly, you may want to do further research. You can read more about my experience here: http://blog.bjornroche.com/2010/03/java-nofx-why-one-project-dropped.html
Swing has problems, and deserves much of the criticism it receives, but if you know what you are doing it can be awesome. I have developed some kick-ass UI's with it (they looked EXACTLY like the designs). Swing is written on top of AWT, which you would think would make it slower, but there are a lot of optimizations that actually make it very fast on most platforms. If I understand correctly, CodenameOne uses a swing-like interface, so in my book, that's another vote for swing: http://www.codenameone.com/
SWT is another option. http://www.eclipse.org/swt/ I have never used it, but I understand you have to do your own memory management with that, which, IMO, takes away a lot of the advantages of using Java. Like I said, though, I've never used it so I could be wrong. It is the native toolkit of Eclipse.

How to learn Java Swing and make GUIs quickly?

I've been coding in Java for the past year, and i think I have solid OO and
basic OOD skills. I'm looking to build a Java GUI on-top of an existing project which is not complex, but I want to finish it as quick as possible. So I'm looking for an API that would abstract all the nitty gritty implementations and let me focus on the core of my minimal viable product.
I really prefer coding with eclipse and not wasting time trying to learn to get used to another IDE. What would you suggest I do?
Here is the crash course in swing.
First thing to learn is the layout managers.This is the big hurdle, they are finicky things and you have to master them.
Second is listeners,without them nothing happens.
Third is the JComponents themselves,you will slowly learn them as you go along. I would recommend using NetBeans GUI builder to play with them and get a feel for them.
Note that most JComponents have different models you can use rather then the default.
Also the only difference between JPanels and JComponents that I can find is that JPanels have layout managers.
A good place for various swing hacks and tutorials is here:
http://www.java2s.com/Tutorial/Java/0240__Swing/Catalog0240__Swing.htm
http://www.java2s.com/Code/Java/Swing-Components/CatalogSwing-Components.htm
Well, actually the GUI Builder in Netbeans is your best bet to make a GUI really fast. You can do it in a matter of minutes if you have the picture in your head about how it's supposed to look like. After that, the only thing left to do is to bind it to your application; more specifically: make the ActionListeners of your buttons for example do whatever they should.
This of course depends on the application's size. If it's small, then making a GUI for it is easy. If, on the other hand, it has 2000 classes, then it can be more complicated, since the GUI will probably be more complicated.
If the application can be modelled as a Model-View-Controller architecture, that would help you a lot.
I think you'll find out that there is no royal way to GUI in Java. Every approach is a pain in the (*). Even if you use a visual GUI builder, it will STILL be a pain in the (*). As a long-term investment in your skills, I recommend you to bite the bullet and learn to build the GUI programmatically. That's what every experienced Swing dev does anyway, so better head for that goal straight away. You could also start with SWT/JFace, but that APi is more difficult and quirky than Swing. RCP adds yet another layer of quirkiness and complexity over SWT/JFace, so I'd stay away from that while still a beginner, and in fact at all times except if making a massive GUI application.
Sounds to me that eclipse RCP could be your friend (if you're looking at a rich client solution). Just grap a distribution of eclipse for plugin development (much faster than installing the plugins to your existing copy), create one of the sample projects and start hacking.
For web applications, I'd recommend the playframework. It integrates quite well with eclipse.

Where are Swing applications used?

Are Swing applications really used nowadays? I don't find a place where they are used. Is it okay to skip the AWT and Swing package (I learned a bit of the basics though)?
If you are writing for the web exclusively, you can probably skip Swing, but otherwise you're absolutely going to run into it. I've never worked on a non-trivial Java app without a Swing GUI.
Also, Swing is one of the better APIs to use. If you use most others, you are going to find them more difficult to use and/or platform incompatible. (If anyone reading this is aware of exceptions to this, please leave comments, I haven't looked for a while and am kind of curious if anything better has become available)
Other JVM languages like JRuby and Jython are often used because of their access to Swing.
You may checkout Swing Sightings.
This website is hosted by SUN and it is dedicated to sw projects that use Swing.
There are a lot of projects using Swing ...
http://java.sun.com/products/jfc/tsc/sightings/
Swing is heavily used in business specific (vertical)/internal application development.
Hmmmm... how about NetBeans? You know, the IDE? It uses Swing.
Swing applications are used in most cases where a Java app runs on the desktop. Sometimes you don't even know - for example, LimeWire is a Java Swing application.
When learning Swing, you'll find that you will come to know those parts of AWT that are still important, such as Event, LayoutManager, Graphics, Font, Color, etc.
You should certainly write Swing for desktop Java, only using AWT to the degree that Swing demands it.
I'm sure people can come up with examples of very good Swing apps besides SQL Squirrel and IntelliJ.
I think that RIA technologies like Flex, Silverlight, etc. are ascendant because the web and services are taking mindshare from desktops. It's not just Swing that's losing out.
Whenever you want to write a desktop GUI app for non-Windows OS, you use Swing as the only sane and guaranteed cross-platform GUI framework.
Besides, Swing has a very good design. I recommend to learn it anyways, to make yourself a better programmer.
Check out Filthy Rich Clients. It explains some of the history of AWT and Swing. Swing, being a lightweight alternative (successor) to most of the AWT classes.
IIRC jEdit is also a Swing app. Quite a popular text editor.
Skip AWT and Swing? To jump where? SWT? Web-based development?
In the broader sense, I have a number of Java applications, although I am not too sure if they use Swing or SWT.
Lot of database tools like SQuirreL SQL Client are written in Java. I think SQuirrel uses stuff from Netbean, which is, of course, Swing based.
yEd is written in Java, probably Swing.
A number of P2P softwares are written in Java, including Frostwire (I see no trace of SWT there, but I can just miss it).
And this list is far from exhaustive!
Lol! I forgot to mention the software suite made by the company I work for! It is quite specialized, used by mobile phone companies to monitor health of their network nodes (superficially looks like a spreadsheet). Totally Swing based.
While Swing has some cross-platform look-and-feel deficiencies and it would be nice if it was updated to support generics, it is still well designed and quite usable. I have always been a fan of the sheer amount of customization offered. SWT is nice and is more native, but you give up some power and control with that as well. In addition, it seems simpler to use, which can be a plus, since Swing can be overly complex due to its flexibility.
Geertjan Wielenga often blogs about applications based on the NetBeans platform, and therefore Swing. The applications range across the board from rather small esoteric applications to very large, mission-critical systems (Boeing Aircraft comes to mind). Many of the enterprise-level applications that Geertjan misses are mentioned on Planet NetBeans. It seems like every few weeks there is an announcement or description of such a program.
As noted above, lots of tools use Swing including the IntelliJ IDEA IDE, a favorite. I'm surprised no one else mentioned it.
Sun also used to maintain a Swing Sightings web site, but it hasn't been updated in a few years.
Where I work, Swing is used in the presentation layer for a very large document management system. In my own development experience I've used Swing for desktop applications in the areas of image processing, device control (video, motors, etc.), math, statistics, and medical devices.
BTW, I agree about the slowness of file choosers. But there are lots of alternatives that will use the native file chooser. It can just be a bit jarring if the L&F's don't match up very well.
EDIT: Oh, and as others have mentioned, it's very easy to use Swing from other languages on the JVM. With Clojure, for example, it is even easier to use than in Java, in my opinion.
There is no universal question to whether it is ok to skip something or not. It's a matter of priorities. While Swing has a lot to teach you (and it is too heavily infused with AWT), if you're never going to be writing GUIs you may be better off investing in something else.
Swing, while ugly as hell, is still used in many places. A quick search on "java swing" in Indeed or dice would reveal many jobs and industries that require it.
Are you skipping it for an exam/interview? Besides really good apps like IntelliJ IDEA and NetBeans, there are lots of Swing like frameworks [SWT (Eclipse), GWT etc.] which you can learn faster with Swing knowledge...
You should probably be looking at JavaFX for future work. As the FAQ states,
Sun is not replacing Swing with JavaFX Script. Instead, JavaFX Script makes Swing easier to use.
Using/learning it will give you a very good understanding of the important Swing concepts, and how they fit in with "the future". I haven't used JavaFX yet, but heard very good things about it.
Armitage tool is made in swing , GUI tool of metasploit framework.

Categories