JTabbedPane class in java
//JTabbedPane
import java.awt.*;
import javax.swing.*;
class JTabbedPane_demo extends JFrame
{
Container con;
JButton btn1, btn2, btn3;
JLabel lbl1, lbl2, lbl3;
JPanel p1, p2;
JTabbedPane tp;
JTabbedPane_demo()
{
con = getContentPane();
con.setLayout(new FlowLayout());
p1 = new JPanel();
p1.setLayout(new FlowLayout());
btn1 = new JButton("BTN - 1");
p1.add(btn1);
btn2 = new JButton("BTN - 2");
p1.add(btn2);
btn3 = new JButton("BTN - 3");
p1.add(btn3);
p2 = new JPanel();
p2.setLayout(new FlowLayout());
lbl1 = new JLabel("LBL - 1");
p2.add(lbl1);
lbl2 = new JLabel("LBL - 2");
p2.add(lbl2);
lbl3 = new JLabel("LBL - 3");
p2.add(lbl3);
tp = new JTabbedPane();
tp.add("Buttons", p1);
tp.add("Labels", p2);
con.add(tp);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
JTabbedPane_demo obj = new JTabbedPane_demo();
obj.setSize(500, 400);
obj.setVisible(true);
}
}
OUTPUT:
Comments
Post a Comment