A Tour Of Swing Servlets

In Part II.you saw how to build user interfaces with the AWT classes. Here, we will
take a top of a supercharged alternative 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, Swing supplies several exciting additions, including tabbed panes, scroll panes, trees, and tables: Even familiar components such as buttons have more capabilities in Swing. For example, a button may rav both an image and a text string associated with it.’Also, the image can be legend  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 light weight is used to describe such elements . The number of classes and interfaces in the Swing packages is substantial, and this chapter provides an’ overview of just a few. Swing is an area that you will want to explore further on you own. .the Swing component classes’ that are used in this book are shown here:


Fundamental to Swing is the JApplet class, which’ extends Applet. Applets that use
Swing must be subclasses of JApplet. JApplct is rich with functionality that is not
found in Japplct, For example, Japplet supports various “panes,” such as the content pane, the glass pane, and the root pane. For the examples in this chapter, we will not be . using most of JApplet’s enhanced features. However, one difference between Applct , and JApplet is important to this discussion, because it is used by the sample applets in this chapter. When adding a component to an instance of JApplet, do not invoke the addO 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:

Container getContentPane( )
The add( ) method of Container can be used to add a component to a content pane.
Its form is shown here: . . ‘
void add (camp)
Here, camp, is the component to be added to the content pane.

reCAPTCHA is required.

Share This