650 Graphical User Interface Components: (Free web host) Part 1 Chapter

650 Graphical User Interface Components: Part 1 Chapter 12 fully qualified package name and class name. Much of each GUI component s functionality is derived from these classes. A class that inherits from the Component class is a Component. For example, class Container inherits from class Component, and class Component inherits from Object. Thus, a Container is a Component and is an Object, and a Componentis an Object. A class that inherits from class Container is a Container. Thus, a JComponentis a Container. Software Engineering Observation 12.1 To use GUI components effectively, the javax.swing and java.awt inheritance hierarchies must be understood especially class Component, class Container and class JComponent, which define features common to most Swing components. Class Component defines the common attributes and behaviors of all subclasses of Component. With few exceptions, most GUI components extend class Component directly or indirectly. One method that originates in class Componentthat has been used frequently to this point is paint. Other methods discussed previously that originated in Component are repaintand update. It is important to understand the methods of class Component because much of the functionality inherited by every subclass of Component is defined by the Component class originally. Operations common to most GUI components (both Swing and AWT) are found in class Component. Good Programming Practice 12.1 Study the methods of class Componentin the Java 2 SDK on-line documentation to learn the capabilities common to most GUI components. A Container is a collection of related components. In applications with JFrames and in applets, we attach components to the content pane, which is an object of class Container. Class Container defines the common attributes and behaviors for all subclasses of Container. One method that originates in class Container is add for adding components to a Container. Another method that originates in class Container is setLayout, which enables a program to specify the layout manager that helps a Containerposition and size its components. Good Programming Practice 12.2 Study the methods of class Containerin the Java 2 SDK on-line documentation to learn the capabilities common to every container for GUI components. Class JComponentis the superclass to most Swing components. This class defines the common attributes and behaviors of all subclasses of JComponent. java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent Fig. 12.3Common superclasses of many of the Swing components. 12. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/7/01

Leave a Reply