import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JTabbedPaneDemo
{
public static void main(String[] arg)
{
JTabbedPaneDemo obj = new JTabbedPaneDemo();
}
public JTabbedPaneDemo()
{
JFrame frame = new JFrame("Tabbed pane demo");
Container c = frame.getContentPane();
JTabbedPane jtp = new JTabbedPane();
jtp.addTab("Country", new CountryPanel() );
jtp.addTab("State", new StatePanel() );
jtp.addTab("City", new CityPanel() );
c.add(jtp);
frame.setSize(300,300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
class CountryPanel extends JPanel
{
public CountryPanel()
{
String item[] = { "India", "China", "UK", "USA", "Russia" };
JComboBox combo = new JComboBox(item);
add(combo);
}
}
class StatePanel extends JPanel
{
public StatePanel()
{
JButton b1 = new JButton("Tamil Nadu");
JButton b2 = new JButton("Maharastra");
JButton b3 = new JButton("Kerala");
add(b1);
add(b2);
add(b3);
}
}
class CityPanel extends JPanel
{
public CityPanel()
{
JCheckBox b1 = new JCheckBox("Chennai");
JCheckBox b2 = new JCheckBox("Delhi");
JCheckBox b3 = new JCheckBox("Mumbai");
add(b1);
add(b2);
add(b3);
}
}
No comments:
Post a Comment