Monday, 3 March 2014

USING AWT CONTROLS,LAYOUT MANAGERS,AND MENUS

CONTROL FUNDAMENTALS IN JAVA

What are the different  types of AWT support  control fundamentals in java..........

The AWT supports the following types of controls:-
  • Labels
  • Push buttons
  • Check boxes
  • Choice lists
  • Lists
  • Scroll bars
  • Text editing
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


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( ).

RESPONDING TO CONTROLS:

Except for labels, which are passive controls, all controls generate events when they are accessed by the user. For example, when the user clicks on a push button, an event is sent that identifies the push button. In general, your program simply implements the appropriate interface and then registers an event listener for each control that you need to monitor. Once a listener has been installed, events are automatically sent to it.

No comments:

Post a Comment