Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the difference between AWTs and Swings  RSS feed

 
Gayathri Chowduru
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

Can anybody please tell me what is the difference between AWT and Swings..

Thanks,
Gayathri Chowduru.
 
Justin Russo
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AWT - has platform dependencies. i.e the API is tied with the OS libraries.

Swing - has no platform dependencies. It is considered as light weight as all its widgets are written in pure Java except JFrame which is tied with native C code.
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swing - has no platform dependencies. It is considered as light weight as all its widgets are written in pure Java except JFrame which is tied with native C code


You are correct but all top level containers namely JFrame, JWindow, JDialog, JApplet etc are OS dependant not only JFrame.

Swing supports Double Buffering and AWT does not support Double Buffering.

Swing has rich set of UI Interface components namely JTable, JTreeView etc
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To say that one has OS or platform dependencies and the other doesn't is a bit misleading. Both depend on a JVM with class libraries to run on; whether the drawing uses OS-native widgets on top of that is generally of lesser concern.

Swing is skinnable (what it refers to as its "Look & Feel"). There are cross-platform skins (Metal) as well as skins that are supposed to look like the native platform (Windows, OS X, Motif, GTK).
 
wm jaban
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://dn.codegear.com/article/26970

mixing the Swing and AWT components will not produce a compile-time error, but the result may not display correctly. The Graphics, Color, Font, layout, listener, ... classes are from AWT, so you typically need to have imports from AWT.
 
varahalaraju penmetsa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gayathri Chowduru:
Hi Everyone,

Can anybody please tell me what is the difference between AWT and Swings..

Thanks,
Gayathri Chowduru.
 
varahalaraju penmetsa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry , unfortunately i have clicked add replay

ya the differences between swings and awt

AWT components are heavy weight components that means they will use some native methods to display or render the components.

because of this native stuff , the look and feel of the awt components are decided by underlaying platform not java. so each component may look or even act differently in different platforms and this inconsistent look and feel spoils the suns philosophy "write once use any ware " thats y they have introduced swings

AWT components places some restrictions like thay can be only opaque and rectangle only we can not change,

so java introduced swings with two advantages
1. light weight components
2. pluggable look and feel
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because of this native stuff , the look and feel of the awt components are decided by underlaying platform not java. so each component may look or even act differently in different platforms and this inconsistent look and feel spoils the suns philosophy "write once use any ware " thats y they have introduced swings


It should be noted that the look-and-feel implementations of Swing are quite close to the underlying OS's native look where those exist (OS X, Windows XP, Motif, GTK). It's been recognized that a look consistent with the native platform is more important than a look that is consistent across platforms (most people don't use the same application on more than a single platform anyway).

Also, the name of the toolkit is "Swing", not "swings".
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!