Friday, 6 February 2015

JTabbedPaneDemo in Java

import java.awt.*;
import javax.swing.*;
public class JTabbedPaneDemo extends JApplet
{
    public void init()
    {
        Container c = getContentPane();
        c.setLayout(new FlowLayout());

        JTabbedPane jtp = new JTabbedPane();
        jtp.addTab("Cities",new panel1());
        jtp.addTab("Color",new panel2());
        jtp.addTab("Taste",new panel3());

        c.add(jtp);
    }
}

class panel1 extends JPanel
{
    public panel1()
    {
        JButton b1 = new JButton("Mumbai");
        JButton b2 = new JButton("Banglore");
        JButton b3 = new JButton("Pune");
        add(b1);
        add(b2);
        add(b3);
    }
}

class panel2 extends JPanel
{
    public panel2()
    {
        JCheckBox c1 = new JCheckBox("Red");
        JCheckBox c2 = new JCheckBox("Green");
        JCheckBox c3 = new JCheckBox("Blue");
        add(c1);
        add(c2);
        add(c3);
    }
}

class panel3 extends JPanel
{
    public panel3()
    {
        JComboBox jcb = new JComboBox();
        jcb.addItem("Vanilla");
        jcb.addItem("Strawberry");
        jcb.addItem("Chocolate");
        add(jcb);
    }
}

/*


*/
Output

No comments:

Post a Comment