Repository navigation
Expand file tree
/
Copy pathJTabbedPanelDemo.java
More file actions
69 lines (61 loc) · 1.67 KB
/
Copy pathJTabbedPanelDemo.java
File metadata and controls
69 lines (61 loc) · 1.67 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
import java.awt.*;
import javax.swing.*;
class Panel1 extends JPanel {
Panel1() {
FlowLayout f1 = new FlowLayout();
setLayout(f1);
JButton b1 = new JButton("OK");
JButton b2 = new JButton("CANCEL");
JButton b3 = new JButton("RETRY");
add(b1);
add(b2);
add(b3);
}
}
class Panel2 extends JPanel {
Panel2() {
FlowLayout f1 = new FlowLayout();
setLayout(f1);
JButton b1 = new JButton("INDIA");
JButton b2 = new JButton("US");
JButton b3 = new JButton("UK");
add(b1);
add(b2);
add(b3);
}
}
class Panel3 extends JPanel {
Panel3() {
FlowLayout f1 = new FlowLayout();
setLayout(f1);
JButton b1 = new JButton("PUNE");
JButton b2 = new JButton("SOLAPUR");
JButton b3 = new JButton("MURTIZAPUR");
add(b1);
add(b2);
add(b3);
}
}
class JTabbedPaneDemo extends JFrame {
JTabbedPaneDemo() {
Container c = getContentPane();
JTabbedPane jtp = new JTabbedPane();
// Create panels for tabs
Panel1 jp1 = new Panel1();
Panel2 jp2 = new Panel2();
Panel3 jp3 = new Panel3();
// Add tabs to JTabbedPane
jtp.addTab("TAB1", jp1);
jtp.addTab("TAB2", jp2);
jtp.addTab("TAB3", jp3);
// Add JTabbedPane to content pane
c.add(jtp);
}
public static void main(String args[]) {
JTabbedPaneDemo f1 = new JTabbedPaneDemo();
f1.setVisible(true);
f1.setTitle("VJTech Frame");
f1.setSize(500, 500);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}