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)

Components
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.

Container
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.

Label
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.
7

Button
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.

Checkbox
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.

CheckboxGroup

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

Choice
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()
11

List
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.

12

Scrollbar
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()
13

TextField
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
14

TextArea
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.

15

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.
16

Layout Manager .....


FlowLayout
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.

BorderLayout
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.

17

Layout Manager .....


GridLayout
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.

CardLayout
The CardLayout class implements

18