AWT and Swing are used for GUI programming in Java. Earlier version of Java (1.0) had a class library called AWT (Abstract Window Toolkit) for GUI programming. AWT used peer-based approach to create GUI. If you used the original AWT to put a text box on a Java window, an underlying peer text box in the background actually handled the text input. Why is AWT not used anymore?
Thus, user interface library called Swing was introduced. The Swing package is part of the JavaTM Foundation Classes (JFC) in the Java platform. The JFC encompasses a group of features to help people build GUI. Swing provides all the components from buttons to split panes and tables. Swing is not a complete replacement of AWT. It packages a set of GUI components and gives you more capable user-interface elements. Swing adds a lot of functionality that was missing from the AWT, like support for keyboard input, copy and paste, drag and drop and focus traversal. Swing adds a more sophisticated set of events, and more advanced interface controls like an editor and scrolling panes, a tree view and a table. Swing is a standard part of Java 2 and higher. Swing 1.1.1 is the last version of Swing, which will be compatible with JDK 1.1. You can mix the components of Swing and AWT and it's documented here: |
Course Content > Session 7 >