ADDING AND REMOVING CONTROLS
To include a control in a window, you must add it to the window. To do this, you must
first create an instance of the desired control and then add it to a window by calling add( ),which is defined by Container. The add( ) method has several forms. The following form
is the one that is used for the first part of this chapter:
Component add(Component compObj)
Here, compObj is an instance of the control that you want to add. A reference to
compObj is returned. Once a control has been added, it will automatically be visible
whenever its parent window is displayed.
Sometimes you will want to remove a control from a window when the control is
no longer needed. To do this, call remove( ). This method is also defined by Container.
It has this general form:
void remove(Component obj)
Here, obj is a reference to the control you want to remove. You can remove all controls
by calling removeAll( ).
0 comments:
Post a Comment