File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Swing Vs AWT Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Swing Vs AWT" Watch "Swing Vs AWT" New topic
Author

Swing Vs AWT

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hi guys! I was having an argument with my friend how Classes in AWT are actually more heavy weight than Swing. I even told him that some classes in the awt package are not entirely written in Java. But I need to give him proof. Do you guys agree? Could you point me to an article? Thanks!


SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
Tim LeMaster
Ranch Hand

Joined: Aug 31, 2006
Posts: 226
How about sun themself:

http://java.sun.com/products/jfc/reference/faqs/index.html#what_swing

http://java.sun.com/products/jfc/tsc/articles/mixing/
"And, since all AWT components are heavyweight and all Swing components are lightweight (except for the top-level ones: JWindow, JFrame, JDialog, and JApplet), these differences become painfully apparent when you start mixing Swing components with AWT components."
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
Mixing HEAVY weight and light components
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

I even told him that some classes in the awt package are not entirely written in Java.

What would they be written in then? AWT classes are all Java. But they call native interfaces.

Also note that as of 1.5.0_09 (I think) the statement that Swing components are lightweight (except for top level components) needs to be redefined. When using the native OS Look and Feel, Swing components like JButton, JLabel, JComboBox, etc now make similar native interface calls to the OS for drawing the widgets. I am sure Sun will still maintain these are lightweight, but arguably so.

I think what they have done is fixed the "mixing HW and LW components" issue to support native look and feel. But I don't know that for a fact.
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
What would they be written in then? AWT classes are all Java. But they call native interfaces.



I'm sure I've read that in a book somewhere... Deitel? Errr...

Thanks for the article guys! I'll just read those then.
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

Originally posted by Timothy Sam:
Deitel?


Well, that would be the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing Vs AWT
 
Similar Threads
If swing is betters graphics handler than awt, why do we need to use awt at all?
Can i use java.awt.Color class?
Swing Components
Layouts and Listeners
AWT or Swing first