0% found this document useful (0 votes)
13 views

Working Procedure With Window

Uploaded by

wooyoung654
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Working Procedure With Window

Uploaded by

wooyoung654
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Powered by AI

Bing

Sure, let’s start with a brief overview of AWT:

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.

Here’s a simple procedure to create AWT classes on Windows:

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.

public class AwtExample extends Frame {


// Your code goes here
}

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.

Button button = new Button("Click me");


add(button);

1. Set Window Properties: You can set various properties for your window such as its size, layout, and visibility.

setSize(400, 400); // Set window size


setLayout(null); // Set layout
setVisible(true); // Make window visible

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…

You might also like