Java Reference
In-Depth Information
As shown in Figure 12-1, the class Container , which is a subclass of the class
Component , is the superclass of all the classes designed to provide GUIs—and, therefore,
all public members of these classes are inherited by their subclasses. Moreover, both the
Container and Component classes are abstract .
The class Component contains many methods that are inherited by its subclasses.
You have used methods such as setSize and setLocation in various GUI
programs. Table 12-1 describes some of the constructors and methods of the class
Component .
TABLE 12-1 Constructors and Methods of the class Component
protected Component()
//Constructor
//Creates a new instance of a component.
public void addComponentListener(ComponentListener lis)
//Adds the component listener specified by lis.
public void addFocusListener(FocusListener lis)
//Adds the focus listener specified by lis.
public void addKeyListener(KeyListener lis)
//Adds the key listener specified by lis.
public void addMouseListener(MouseListener lis)
//Adds the mouse listener specified by lis.
public void addMouseMotionListener(MouseMotionListener lis)
//Adds the mouse motion listener specified by lis.
public void removeComponentListener(ComponentListener lis)
//Removes the component listener specified by lis.
public void removeKeyListener(KeyListener lis)
//Removes the key listener specified by lis.
public void removeMouseListener(MouseListener lis)
//Removes the mouse listener specified by lis.
1
2
public void removeMouseMotionListener(MouseMotionListener lis)
//Removes the mouse motion listener specified by lis.
public Color getBackground()
//Returns the background color of this component.
public Color getForeground()
//Returns the foreground color of this component.
public void setBackground(Color c)
//Sets the background color of this component to color c.
 
Search WWH ::




Custom Search