Applications in Java.: Java AWT (Abstract Window Toolkit) Is An API To Develop GUI or Window-Based
Applications in Java.: Java AWT (Abstract Window Toolkit) Is An API To Develop GUI or Window-Based
applications in java.
Window
The window is the container that have no borders and menu bars. You
must use frame, dialog or another window for creating a window.
Panel
The Panel is the container that doesn't contain title bar and menu
bars. It can have other components like button, textfield etc.
Frame
The Frame is the container that contain title bar and can have menu
bars. It can have other components like button, textfield etc.
Method Description
To create simple awt example, you need a frame. There are two ways to
create a frame in AWT.
import java.awt.*;
class First extends Frame{
First(){
Button b=new Button("click me");
b.setBounds(30,100,80,30);// setting button position
add(b);//adding button into frame
setSize(300,300);//frame size 300 width and 300 height
setLayout(null);//no layout manager
setVisible(true);//now frame will be visible, by default not visible
}
public static void main(String args[]){
First f=new First();
}}
import java.awt.*;
class First2{
First2(){
Frame f=new Frame();
Button b=new Button("click me");
b.setBounds(30,50,80,30);
f.add(b);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[]){
First2 f=new First2();
}}
Java AWT Button
The button class is used to create a labelled button that has platform
independent implementation. The application result in some action when the
button is pushed.