-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGridBag.java
More file actions
39 lines (34 loc) · 900 Bytes
/
GridBag.java
File metadata and controls
39 lines (34 loc) · 900 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
29
30
31
32
33
34
35
36
37
38
39
import java.awt.*;
public class GridBag extends Frame{
GridBag()
{
setSize(400,400);
setVisible(true);
setLocation(500,200);
setTitle("GridBagLayout");
GridBagLayout gl = new GridBagLayout();
GridBagConstraints gc = new GridBagConstraints();
setLayout(gl);
GridBagLayout gl2 = new GridBagLayout();
this.setLayout(gl2);
gc.gridx=0;
gc.gridy=0;
Button b = new Button("Button1");
add(b,gc);
gc.gridx=1;
gc.gridy=0;
Button b1 = new Button("Button2");
add(b1,gc);
gc.gridx=0;
gc.gridy=1;
Button b2 = new Button("Button3");
add(b2,gc);
gc.gridx=1;
gc.gridy=1;
Button b3 = new Button("Button4");
add(b3,gc);
}
public static void main(String[] args) {
GridBag g = new GridBag();
}
}