Chapter 16. The Swing Library


Java™ 2 Primer Plus
By Steven Haines, Steve Potts

Table of Contents
Part III:  Graphical User Interfaces

You will learn about the following in this chapter:

  • What Swing is

  • How Swing applications are Structured

  • The role of the JComponent class

  • How the basic Swing components work

In Chapter 13, "Abstract Windows Toolkit," we discussed the limitations of the AWT. To summarize the discussion, we concluded that the AWT was a good first try at developing a Graphical User Interface (GUI), but that several enhancements were needed before the Java GUI toolkit would be a really valuable tool.

The Java doctrine of "write once, run anywhere" has a corollary that states "write once, run it forever." In other words, new releases of the JVM are not supposed to break existing applications and applets. This doctrine placed so many constraints on the GUI team that the decision was made to create an entirely new toolkit that would coexist with the AWT, but would not deprecate it. This decision freed up the team to make huge changes in the new GUI system that would have broken the AWT if it were retrofitted.

The result is that we now have two sets of GUI classes, the original AWT, and the newer GUI called the Java Foundation Classes (JFC), or Swing. Swing originated as a 100% Java GUI called the Netscape Internet Foundation Classes (IFC). Netscape was able to convince Sun Microsystems that the Java vendor needed to drive this new interface. Sun agreed, took over the development of the IFC, and renamed the product the Java Foundation Classes (JFC). Some of the early demos of the JFC featured swing music from Duke Ellington. This led to the nickname "Swing." This nickname stuck and Swing is the name that you normally hear when the GUI is discussed.

In this chapter we are going to introduce you to the Swing library. We will start with a discussion of the additional features that Swing brings to your development efforts. Following that, we will look at the architecture of a Swing component. Finally, we will work examples that show you how to use the Swing version of components that you are already familiar with from the AWT. In Chapter 17, "Advanced Swing," you will learn how to use the components that were introduced with Swing that have no AWT counterpart.


    Java 2 Primer Plus
    Java 2 Primer Plus
    ISBN: 0672324156
    EAN: 2147483647
    Year: 2001
    Pages: 332

    Similar book on Amazon © 2008-2017.
    If you may any questions please contact us: