Swing is a set of classes that provides more powerful and flexible components than are possible with the AWT. In addition to the familiar components, such as buttons, check boxes, and labels, Swings supplies several exciting addition, including tabbed panes, scroll panes, trees, and tables. Even familiar components such as buttons have more capabilities in swing. For example, a button may have both an image and a text string associated with it. Also, the image can be changed as the state of the button changes.
Unlike AWT components, swing components are not implemented by platform-specific code. Instead, they are written entirely in Java and, therefore, are platform-independent. The term lightweight is used to describe such elements.
Swing is a large system, and it has many features that you will want to explore on your own. For example, Swing provides toolbars, tooltips, and progress bars. Also, Swing components can provide a pluggable look and feel, which means that it is easy to substitute another appearance and behavior for an element. This can be done dynamically. You may even design your own look and feel. The swing approach to GUI components might replace the AWT classes.Swing is just one part of the Java Fundation Classes(JFC).
The swing related classes are contained in javax.swing and its subpackages, such as javax.swing.tree.
Fundamental to Swing is the JApplet class, which extends Applet. Applets that use Swing must be subclasses of JApplet. JApplet is rich with functionality that is not found in Applet. For example, JApplet supports various “panes”, such as the content pane, the glass pane, and the root pane. There are one main difference between Applet and JApplet is, when adding a component to an instance of JApplet, do not invoke the add() method of the applet. Instead, call add() for the content pane of the JApplet object. The content pane can be obtained via the method shown here:
The add() method of Container can be used to add a component to a content pane. Its form is show here.