AWT controls

 AWT controls

  • The java GUI classes are contained in the java.awt package.
  •  AWT package provides full support for user interface, components like labels, buttons, checkboxes, textfields, scrollbars, menus etc.

1)Labels

  •  A Label is a string that appears on a graphical user interface.
  • these class defines three constructors.

            1)Label()
            2)Label(String str)
            3)Label(String str, int align)
  •  Here, str is the text for the label.
2)Buttons
  •  A Button is a component that appears as a push button.
  •  A button is a component that contain a label and that generates an event when it is pressed.
  •  this class defines two constructor.
            1)Button()
            2)Button(String str)
  •  Here str is the text for the button.
3)Checkbox
  • A Checkbox is a component that combines a label and a small box.
  •  it is a control that is used to turn an option on or off.
  • the constructor are as follow:
            1)Checkbox()
            2)Checkbox(String str)
            3)Checkbox(String str,boolean state)
            4)Checkbox(String str,boolean state,CheckboxGroup grp)

  •  The first form creates a checkbox whose label is blank.
  •  In the second form str is the text for the check box.
  •  In the third form if state is true, a check mark appears in the box.
  • The fourth form used to group several check boxes together.
  • The parameter grp is referenced to the check box group.
4)CheckboxGroup 
  •  A CheckboxGroup is a set of check boxes.
  •  in this group only one check box in the group can be checked at one time.
  • These check box group are often called radio buttons.
  •  For, this type of Checkbox you must first define the group to which they will belong and then specify that group whenyou construct the checkbox.
  • CheckboxGroup()
5)Choice
  • A choice is a component that provides a list of menu. When user clicks on a choice, it displays whole list of choice and then a selection can be made.
  • it can have only one item selected at a time. Choice shows the currently selected item.
  •  Choice define the only one constructor:
  • Choice()
6)List
  •  A List is a component that allows a user to select one or more items. If the list is large then it will automatically provide scroll bars so that user may see the entire list.
  •  An item event is generated when a user selects or deselects one of the item.
  •  It defines the following constructor:
              1)List()
              2)List(int rows)
              3)List(int rows,boolean multiple)
  • Here, in the second form rows is the number of items that are visible to user.
  •  In the third form if multiple is true , a user may select multiple entries in a list.
  • Otherwise only one item may be selected.
7)Scrollbar
  •  Scrollbars are used to select any int values between a specified minimum and maximum.
  • A scroll bar contains a slider that may be dragged to continuously vary its value.
  • it defines the following constructor:
  • Scrollbar()
  • Scrollbar(int orientation)
  • Scrollbar(int orientation,int value,int width,int min,int max)
8)TextField 
  •  A textField allows a user to enter one line of text.
  • TextField allow the user to enter strings and to edit the text using the arrow keys, cut and paste keys, and mouse selection.
  • It defines the following constructor:
  • TextField()
  • TextField(String str)
  • TextField(int cols)
  • TextField(String str, int cols)
  •  Here, str is the text for the field. The argument cols indicate the width of a field in character.
9)TextArea 
  •  A textArea allows a user to enter multiple lines of text. Sometimes a single line of text input is not enough for a given task.
  •  To handle these situation, the AWT includes a simple multiline editor called TextArea.
  •  It has the following constructor:
  • TextArea()
  • TextArea(String str)
  • TextArea(int rows,int cols)
  • TextArea(String str,int rows,int cols)
  • TextArea(String str,int rows,int cols,int scrollbars)
  •  Here, str is the text for the area. The rows and cols arguments indicate the number of rows and columns in the component.
10)Canvas
  • A canvas provides a rectangular area on which we can draw. This is valuable because we can create graphs and other diagrams on the canvas by using methods of the Graphics class.
  •  The canvas class extends component class.
  • it defines the following constructor.
  • Canvas()
11)Menubars and Menus
  •  A window can have a menubar associated with it.A menu bar displays a list of top level menu choice.
  •  Each choice is associate wiuth a drop down menu. This concept is implemented by the following classes:Menubar, Menu and MenuItem 

  •  In short, a menu object contains a list of MenuItem objects.
  •  Each menu object contains a list of MenuItem objects. Each MenuItem object represents something that can be selected by the user.
  •  Menu is a superclass of MenuItem. We can also create a hierarchy of nested submenus.
  • It is also possible to include checkable MenuItem.

No comments:

Post a Comment