-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAWTExample.java
More file actions
70 lines (59 loc) · 1.64 KB
/
Copy pathAWTExample.java
File metadata and controls
70 lines (59 loc) · 1.64 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package java1.awt;
import java.awt.*;
import java.awt.event.*;
/**
* Java 1.0 AWT (Abstract Window Toolkit) Example Demonstrates basic GUI components
* NOTE: AWT is the original GUI framework in Java 1.0
*/
public class AWTExample extends Frame implements ActionListener
{
private Button button;
private Label label;
private TextField textField;
private int clickCount = 0;
public AWTExample()
{
setTitle("Java 1.0 AWT Example");
setSize(400, 300);
setLayout(new FlowLayout());
// Label
label = new Label("Welcome to Java 1.0 AWT");
add(label);
// TextField
textField = new TextField(20);
add(textField);
// Button
button = new Button("Click Me");
button.addActionListener(this);
add(button);
// Window listener for closing
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == button)
{
clickCount++;
label.setText("Button clicked " + clickCount + " times");
System.out.println("Button clicked! Text: " + textField.getText());
}
}
public static void main(String[] args)
{
System.out.println("=== Java 1.0 AWT Example ===\n");
System.out.println("AWT (Abstract Window Toolkit) provides:");
System.out.println("- Basic GUI components (Button, Label, TextField)");
System.out.println("- Layout managers (FlowLayout, BorderLayout, GridLayout)");
System.out.println("- Event handling (ActionListener, WindowListener)");
System.out.println("- Graphics capabilities");
System.out.println("\nCreating AWT window...");
new AWTExample();
}
}