You are on page 1of 18

Abstract Window Toolkit (AWT)

introduce Java graphical components (e.g. Textfields, Buttons, and Labels) show how Java programs can be made to react to user actions on Java graphical components show how Java applications can be run from inside web browsers (Java applets)

An abstract class which encapsulates all of the attributes of a visual component. Responsible for managing keyboard input and focus management , mouse input and enter/exit notification, on-screen size and position, etc. Font, foreground and background colors.

An abstract subclass of Component, which has additional methods that allow other Components to be nested inside it. Responsible for laying out any components it contains. (eg. LayoutManager)

Panel Class
The Panel class is a very simple concrete subclass of Container. Used to reserve a rectangular portion of a Frame to place other components. Components may be added to a Panel by using add(). resize(), reshape(), and move() methods can be used on components.

Canvas Class
The Canvas class is a very simple subclass of Component. You can layer any kind of appearance and behavior onto a Canvas. allow you to reserve a portion of a Frame to draw in.

The Label class is a very simple subclass of Canvas. Knows how to align a particular String inside the bounds of the Label component. The Font and Color are part of the basic definition of a Component. These attributes are manipulated using the getFont()/setFont() and getForeground()/setForeground() method pairs. LEFT,RIGHT and CENTER are 3 constants to indicate alignment in Label.

A Button is a component that uses press and release actions. A Button is labeled with String which cant be aligned. By default label position of String is CENTRE.

The Checkbox class is like a Label with a small button next to it, which can toggle the state of a check mark. The getState() and setState() methods are used to get and set the current state of check mark. A String is passed as a label for Checkbox. Boolean value is also passed to set the state.


( radio button)

The CheckboxGroup class is like a Label with a small button next to it, which can toggle the state of a check mark. The CheckboxGroup class is used to select a boolean condition. To create a group of choices which can only be selected one at a time. Methods used are getCheckboxGroup(), setCheckboxGroup(), getCurrent() and setCurrent().

The Choice class is used for creating a drop-down selection menu. only currently selected item is displayed. When the user clicks on it, the whole menu of choices drops-down and a new selection can be made. Methods used are countItem() addItem.getSelectedItem(),and getSelectedIndex()

The List class provides a compact, multiple-choice, scrolling selection list. A List object can be constructed to show any number of choices in the visible window Multiple selection is possible.


Scrollbar are used to select continuous values between a specified minimum and maximum. Horizontal and vertical orientation controls are specified using the constants HORIZONTAL and VERTICAL. getValue() and setValue() methods can be used to get and set the current value of a Scrollbar. Min and max values can be retrieved using getMinimum() and getMaximum()

TextField class implements a single-line text entry area. Constructor allows to specify width and default value. setEditable() is used to freeze the field. isEditable() to check editability of the field. setText()and getText() are used to set and get the current value. select() and selectAll() are used for selecting of text. setEchoCharacter() sets the single character that the TextField will use for all characters typed in. echoCharIsSet() is used to check whether the

setEchoCharacter() is applied on the field.

getEchoChar()is used to get the character being echoed

TextArea class implements a plain-text, multi-line editor text entry area. Constructor takes a String value as the initial text, followed by the number of columns and rows of text to display. appendText() appends its String parameter to theend of the buffer. insertText() inserts its String parameter . replaceText() copies characters from its String parameter.


Layout Manager
The LayoutManager is used to position each of the contained Components. Each Container object has a layout manager which is an instance of any class that implements the LayoutManager interface. setLayout() method is supported by the layout managers. Each class that implements LayoutManager keeps track a list of Components which are stored using a String name. LayoutManager is notified each time a component is added to a Panel. minimumLayoutSize() and preferredLayoutSize() are used when a resizing is needed. preferredSize() and minimumSize() should be properly implemented by a component.

Layout Manager .....

The FlowLayout class implements a simple layout style similar to words flow in a text editor. Components are laid out from the upper-left corner , left to right and top to bottom. LEFT, RIGHT, or CENTER, is passed to the constructor to align the flow.

The BorderLayout class implements a common layout style for toplevel windows. It has four narrow, fixed-width components at the edges, and one large area in the centre that grows and shrinks in 2 dimension. Each of these area is named with a String.North, South, East, and West represent the four sides, and Center is the middle area.


Layout Manager .....

The GridLayout class implements a simple layout style with an uniform grid of components. Constructor is used to define the number of rows and columns in the Panel layout.

The CardLayout class implements