Wednesday, 15 February 2012

What is Difference between AWT and Swing? | Java Applets

Swing provides a richer set of components than AWT. They are 100% Java-based. AWT on the other hand was developed with the mind set that if a component or capability of a component werent available on one platform, it wouldnt be available on any platform. Due to the peer-based nature of AWT, what might work on one implementation might not work on another, as the peer-integration might not be as robust. There are a few other advantages to Swing over AWT:
  1. Swing provides both additional components and added functionality to AWTr eplacement components
  2. Swing components can change their appearance based on the current “look and feel” libraiy that’s being used
  3. Swing components follow the Model-View-Controller (MVC) paradigm, and thus can provide a much more flexible UI.
  4. Swing provides “extras’ for components, such as:
  5. Icons on many components
  6. Decorative borders for components
  7. Tool tips for components
  8. Swing components are lightweight (less resource intensive than AWT)
  9. Swing provides built-in double buffering
  10. Swing provides paint debugging support for when you build your own components
Swing also has a few disadvantages:
  1. It requires Java 2 or a separate JAR file
  2. If you’re not very careful when programming, it can be slower than AWT (all components are drawn)
  3. Swing components that look like native components might not act exactly like native components.

No comments: