Awt
The Abstract Window Toolkit (AWT) is Java's original platform-independent windowing, graphics, and user-interface widget toolkit.
Swing
Swing is the primary user-interface toolkit in Java and is shipped with the standard Java SDK
Better newer old
Example |
---|
"I find that the swing library is easier to use than awt although you do still have to use awt for listeners" from question Creating a Frame with MenuBar - Size not recognized by pack(), menubar is being cutoff |
"You can read all over the web that awt is old and deprecated and swing is old but newer than awt and should be preferred over awt whenever possible" from question When to use AWT along with Swing and when not? "Yes swing has newer and better api s than awt" from question Two JPanels, requesting focus and Keyboard input "Swing has newer and better api s than awt" from question JTextField respond to key event AFTER the text is updated |
"That is used in old awt applications;swing has newer and better apis" from question JTable in Swing |
"That is an old awt solution;swing has newer and better apis" from question EventHandler acting weirdly and weird color patches |
"Consider using swing which has much better performance over the old heavyweight awt" from question Beginner Java Program-- cannot get key pressed to work |
"Swing is far better then awt and should be educated to people who is writing gui-based java for the first time" from question Java calculator decimal point "Swing is far better than the obsolete awt library" from question How do I add padding with Container? |
"Swing is better and few people remember how to use awt components" from question What is the difference between JApplet and Applet, and which should I use? "Swing or javafx would be better than awt" from question How to use custom axis type? (Java) |
Useful
Example |
---|
"As far as when awt may be more useful than swing -" from question What is the difference between Swing and AWT? |
"Are there any cases where awt is more useful advised to use than swing or vice-versa" from question What is the difference between Swing and AWT? |
Jframe frame swing
Example |
---|
"Consider using swing instead of awt jframe instead of frame;swing is richer" from question Need help to display inputs of a Java's form on an other frame |
"Swing has more or less deprecated awt so you should extend jframe instead of frame" from question Java - Game of Life - Trouble with displaying graphics |
Event thread frameworks
Example |
---|
"Keep in mind that awt swing have a dedicated thread that does gui work handling event handlers repainting the gui etc;if you do long-running things on that thread swing will not repaint" from question Java GUI JProgressBar not painting |
"If you need to modify swing components from threads other than the awt event dispatch thread use;swing is not thread-safe" from question Threads and jtable |
"This applies to many other ui frameworks as well such as swing awt and the event dispatch thread" from question Toggle button .isSelected() is true, but visually not changing in JavaFX |
Flexible richer out-of-the-box
Example |
---|
"Swing is generally more configurable and flexible to use;you should avoid mixing awt and swing components within the same ui ui tend not to play well together" from question Swing button vs AWT button? |
"In swing has more features than the awt components" from question If Swing has more features to design a form. Then what is the use of AWT in java? |
"Use a swing gui not an awt gui since swing is much more powerful and flexible than awt" from question Paint ArrayList of Shape Objects to Frame |
"Swing will save your more time than awt as all the code of components of swing are purely written in java whereas of awt code of components are written in native language that is other than java thus compilation time of awt is more than swing" from question Clearing screen vs drawing on top? |
"Well swing is richer in terms of out-of-the-box components than awt" from question Do I have to learn AWT before learning Swing? |
Others
Example |
---|
If you are planning to move your gui onto multiple platforms then go with awt;otherwise swing gives you a much broader set of components to work with from question Java's AWT or Swing for GUI construction? |
Swing is relatively similar to awt apart from the fact that swing has more capabilities awt is probably the simplest form to start out with and has most if not all of the tools to complete your project hope this helps from question Simple Java Game Graphical Interface |
Performance swing components are generally slower and buggier than awt due to both the fact that cons are pure java and to video issues on various platforms from question Is Java Swing still in use? |
That is old code when using awt;swing has newer and better api s from question JTextField accept only numbers and one dot Keyevents are generally used in awt;swing has newer and better api s to use in most cases from question Prevent breaking of JTextField / JDialog with repeated transferFocus() That is probably the oldest solution and was used in awt;swing has newer and better api s which you should be using from question Key listener java - number limitation |
In general avoid awt for swing which has much greater power and flexibility although it too is showing its age just less so than awt from question Java.awt: Second TextArea is not shown |
Applet awt is a relatively discarded technology;the newer japplet swing has no longer that large a browser support too from question Why isnt my Java Echo applet working? |
Awt componentsare heavy weight;swing occupies less memory space from question What is the difference between Swing and AWT? |
The swing library is much more portable than the awt library from question Creating a Frame with MenuBar - Size not recognized by pack(), menubar is being cutoff |
Note first there is no combobox item in awt there is jcombobox in swing which is better to use than choice of awt from question Adding an Action listener to a JComboBox |
Awt is not mvc based;swing works faster from question What is the difference between Swing and AWT? |
Due to swt looks more native than awt swing from question SWT and AWT, what is the difference? |
Swing was said that awt is faster than swing as swing uses the platform component but due the arrival of faster processor etc .. from question When you use Frame or JFrame in Java? |
A panel has functionality the same as a canvas but swing is more advanced and has better features than awt from question Using Java AWT components |
Awt is really out of date people have more experience with swing no days and even javafx from question Control is not going through if statement |
The keylistener is an older interface from the awt days the keylistener still ok to use the keylistener with swing but is more of a general listener from question KeyListeners vs Keybindings? |
Alternate way is to use awt - which is an older and worse technology than swing and in that case you can t use flowlayout - it puts all the components into one row from question I can't rearrange text in JAVA |
Swing occupies less memory space;awt occupies more memory space from question What is the difference between Swing and AWT? |
The awt approach seems closer to bare metal but since jdk 6 brought a lot of improvements in swing rendering pipeline i would go the swing java2d approach from question How to effectively render video in Java (AWT??) |
Generally swing is more efficient and advanced than awt from question Java Style About JFrame and DefaultCloseOperation |
Use swing follow the threading rules which are hardly likely to be more onerous than awt and enjoy from question Must all methods in AWT classes, i.e. non-Swing ones, be called in the EDT? |
I mean by light weight i thought maybe the swing components occupy less memory than the awt components from question Swing components are light-weight? |
Don t use a keylistener that is old code when using awt;swing has newer and better api s from question NullPointerException when calling getSelectedItem() on an editable JComboBox |
Apple recommends using awt s filedialog instead of the swing file chooser because filedialog acts more like the native macos file dialog from question AWT FileDialog filename copy/paste keystrokes? |
Awt does not work faster;swing componets are light weight from question What is the difference between Swing and AWT? |
I know you re thinking why did i use awt instead of swing but at the moment i am more comfortable with awt from question Add a scrollbar/scrollpane to frame in AWT |
Awt is a thin layer of code on top of the os whereas swing is much larger;swing also has very much richer functionality from question What is the difference between Swing and AWT? |
That is an old approach when using awt;swing has better api s from question Having trouble understanding JList |