-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayout.java
More file actions
64 lines (54 loc) · 1.31 KB
/
layout.java
File metadata and controls
64 lines (54 loc) · 1.31 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
package mayank;
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
import java.awt.event.*;
public class layout extends JFrame {
private JButton lb;
private JButton rb;
private JButton cb;
private FlowLayout layout;
private Container container;
public layout(){
super("the title");
layout=new FlowLayout();
setLayout(layout);
container=getContentPane();
lb=new JButton("left");
lb.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
layout.setAlignment(FlowLayout.LEFT);
layout.layoutContainer(container);
}
}
);
add(lb);
cb=new JButton("center");
cb.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
layout.setAlignment(FlowLayout.CENTER);
layout.layoutContainer(container);
}
}
);
add(cb);
rb=new JButton("right");
rb.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
layout.setAlignment(FlowLayout.RIGHT);
layout.layoutContainer(container);
}
}
);
add(rb);
}
public static void main(String[] args) {
layout ob=new layout();
ob.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ob.setVisible(true);
ob.setSize(300,200);
}
}