-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_awt_app.java
More file actions
28 lines (24 loc) · 811 Bytes
/
basic_awt_app.java
File metadata and controls
28 lines (24 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.awt.*;
import java.awt.event.*;
public class BasicAWTExample {
public static void main(String[] args) {
Frame frame = new Frame("Basic AWT Example");
Button button = new Button("Click Me");
button.setBounds(50, 100, 80, 30);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Button Clicked!");
}
});
frame.add(button);
frame.setSize(300, 200);
frame.setLayout(null);
frame.setVisible(true);
// Close the frame on close button click
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
}
}