By,
Santosh
Java Abstract Windowing Toolkit (AWT) is an API to develop GUI or window-based application in java.
Java AWT components are platform-dependent i.e. components are displayed according to the view of operating system. Its components uses the resources of system because AWT is heavyweight.
The java.awt package provides classes for Abstract Windowing Toolkit (AWT) API such as TextArea, TextField, Label, Choice , CheckBox, RadioButton, List etc.
Java Abstract Windowing Toolkit (AWT) Hierarchy :-
Container
The Container is a component of AWT that can contain another components like textarea, radiobuttons, checkboxs, list etc. The classes that extends Container class are known as container such as Panel, Frame, and Dialog.
Window
The window is the container that have no menu bars and borders. You must use dialog, frame or another window for create a window.
Panel
The Panel is the container that doesn't contain menu bar and title bars. It can has another components like checkbox, textfield , button etc.
Frame
The Frame is the container that can have menu bars and contain title bar. It can has another components like checkbox, textfield , button etc.
Useful Methods for Abstract Windowing Toolkit Component class :-
public void add(Component com) :- insert a component.
public void setSize(int width - Component, int height - Component) :- sets the size of component.
public void setLayout(LayoutManager lm) :- defines a layout manager for a component
public void setVisible(boolean status (Ture / false)) :- changes visibility of a component.
AWT Example
import java.awt.*;
class AwtTest extends Frame
{
AwtTest()
{
Button b1=new Button("click here");
b1.setBounds(30,100,80,30);
// setting button position on screen
add(b1);
//adding button on frame of awt
setSize(454,454);
//frame size we provide into setSize( ) method width = 454 and height = 454
setLayout(null);
//Here we defined null for setLayout( ) method means No layout manager.
setVisible(true);
//now frame is visible.
}
public static void main(String args[])
{
AwtTest at=new AwtTest ();
}
}
Java AWT Event and Listener (Java AWT Event Handling) :-
Something happens on screen that for Change the state of an objector screen is known as an event. For example, scroll down, scroll up, click, double click, dragging mouse etc. The java.awt.event package provides many event classes and Listener interfaces for event handling.
ActionEvent - ActionListener
MouseEvent - MouseListener and MouseMotionListener
MouseWheelEvent - MouseWheelListener
KeyEvent - KeyListener
ItemEvent - ItemListener
TextEvent - TextListener
AdjustmentEvent - AdjustmentListener
WindowEvent - WindowListener
ComponentEvent - ComponentListener
ContainerEvent - ContainerListener
FocusEvent - FocusListener
Santosh
Java Abstract Windowing Toolkit (AWT) is an API to develop GUI or window-based application in java.
Java AWT components are platform-dependent i.e. components are displayed according to the view of operating system. Its components uses the resources of system because AWT is heavyweight.
The java.awt package provides classes for Abstract Windowing Toolkit (AWT) API such as TextArea, TextField, Label, Choice , CheckBox, RadioButton, List etc.
Java Abstract Windowing Toolkit (AWT) Hierarchy :-
Container
The Container is a component of AWT that can contain another components like textarea, radiobuttons, checkboxs, list etc. The classes that extends Container class are known as container such as Panel, Frame, and Dialog.
Window
The window is the container that have no menu bars and borders. You must use dialog, frame or another window for create a window.
Panel
The Panel is the container that doesn't contain menu bar and title bars. It can has another components like checkbox, textfield , button etc.
Frame
The Frame is the container that can have menu bars and contain title bar. It can has another components like checkbox, textfield , button etc.
Useful Methods for Abstract Windowing Toolkit Component class :-
public void add(Component com) :- insert a component.
public void setSize(int width - Component, int height - Component) :- sets the size of component.
public void setLayout(LayoutManager lm) :- defines a layout manager for a component
public void setVisible(boolean status (Ture / false)) :- changes visibility of a component.
AWT Example
import java.awt.*;
class AwtTest extends Frame
{
AwtTest()
{
Button b1=new Button("click here");
b1.setBounds(30,100,80,30);
// setting button position on screen
add(b1);
//adding button on frame of awt
setSize(454,454);
//frame size we provide into setSize( ) method width = 454 and height = 454
setLayout(null);
//Here we defined null for setLayout( ) method means No layout manager.
setVisible(true);
//now frame is visible.
}
public static void main(String args[])
{
AwtTest at=new AwtTest ();
}
}
Java AWT Event and Listener (Java AWT Event Handling) :-
Something happens on screen that for Change the state of an objector screen is known as an event. For example, scroll down, scroll up, click, double click, dragging mouse etc. The java.awt.event package provides many event classes and Listener interfaces for event handling.
ActionEvent - ActionListener
MouseEvent - MouseListener and MouseMotionListener
MouseWheelEvent - MouseWheelListener
KeyEvent - KeyListener
ItemEvent - ItemListener
TextEvent - TextListener
AdjustmentEvent - AdjustmentListener
WindowEvent - WindowListener
ComponentEvent - ComponentListener
ContainerEvent - ContainerListener
FocusEvent - FocusListener
No comments:
Post a Comment