Working Procedure With Window
Working Procedure With Window
Bing
Java AWT (Abstract Window Toolkit) is an API used to develop Graphical User Interface (GUI) or windows-based
applications in Java. AWT components are platform-dependent, which means they are displayed according to the view of
the operating system. The java.awt package provides classes for AWT API such as TextField, Label, TextArea,
RadioButton, CheckBox, Choice, List, etc.
1. Create a Java Class: You can create a new Java class in any IDE of your choice. For example, you can create a new
file named AwtExample.java.
2. Import AWT Package: At the beginning of your Java class, import the java.awt package. This package contains all
the classes you’ll need to create window-based applications.
import java.awt.*;
1. Extend the Frame Class: The Frame class in the java.awt package can be used to create a top-level window. Extend
this class to create your own window.
1. Add Components: You can add various components to your window such as buttons, labels, text fields, etc. These
components are also part of the java.awt package.
1. Set Window Properties: You can set various properties for your window such as its size, layout, and visibility.
1. Handle Events: You can handle various events such as button clicks, window closing, etc. This is done by
implementing various listener interfaces.
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Button clicked");
}
});
1. Run Your Application: Finally, you can run your application. You should see a window with a button. When you
click the button, “Button clicked” will be printed to the console.
Remember, AWT components are platform-dependent, which means they are displayed according to the view of the
operating system. So, the look and feel of your AWT application may vary based on the platform it is running on…