-
Notifications
You must be signed in to change notification settings - Fork 0
/
AwtExample1.java
40 lines (27 loc) · 936 Bytes
/
AwtExample1.java
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
// importing Java AWT class
import java.awt.*;
// extending Frame class to our class AWTExample1
public class AwtExample1 extends Frame {
// initializing using constructor
AwtExample1() {
// creating a button
Button b = new Button("Click Me!!");
// setting button position on screen
b.setBounds(30,100,80,30);
// adding button into frame
add(b);
// frame size 300 width and 300 height
setSize(300,300);
// setting the title of Frame
setTitle("This is our basic AWT example");
// no layout manager
setLayout(null);
// now frame will be visible, by default it is not visible
setVisible(true);
}
// main method
public static void main(String args[]) {
// creating instance of Frame class
AwtExample1 f = new AwtExample1();
}
}