This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Get Programming with Java (MEAP only) and have Peggy Fisher on-line!
See this thread for details.
Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Swing vs AWT  RSS feed

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi everybody,
Q1) What is the difference between Swing and AWT ? What exactly are lightweight components--- because some Swing components are also heavyweight like JFrame?
Q2) What are the advantages of Swing over AWT?
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heavyweight Component (AWT) - Uses native peers to supply graphical representation (Heavy). For example on Windows button looks like Windows button but on Unix the button looks like a Motif button.
Lightweight Component (Swing) - Doesn't use native peers to supply graphical representation (Light). Component itself handles all graphics; therefore a button will have the same look and feel running on any system (Mac, Unix, or Windows).
Heavy and light doesn't refer to the amount of work a component does just how it gets it done (Heavy - includes peer, Light - no peer needed).
Swing provides following advantages over AWT:
1. More dynamic components
2. More complex components (i.e., JTable)
3. New layout manager (Box)
4. Pluggable look and feel
NOTE: Since swing sits below AWT container you can mix AWT and Swing in any java program!
 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Manfred.

What does the NOTE statement mean???
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The NOTE statement means that you can use both AWT and swing elements in any java GUI. For example, lets suppose you have an AWT Panel that contains an AWT List. If you want to use a JPanel to get a border around the AWT List you just replace the AWT Panel with the JPanel.
I was just letting you know that if you decide to use Swing you are not stuck using all Swing components if you like the AWT alternative.
Good Luck,
Manfred.
 
Whatever you say buddy! And I believe this tiny ad too:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!