Friday, July 23, 2010

Tabbed pane

Buzz It
import javax.swing.*;
import java.awt.*;
import java.applet.*;
/*
<applet code="tpane" width=200 height=200>
</applet>
*/
public class tpane extends JApplet
{
public void init()
{
JTabbedPane p1 = new JTabbedPane();
p1.addTab("cities",new city());
p1.addTab("colors",new color());
getContentPane().add(p1);
}
}
class city extends JPanel
{
public city()
{
JButton b1 = new JButton("new york");
add(b1);
JButton b2 = new JButton("las vegas");
add(b2);
JButton b3 = new JButton("chicago");
add(b3);
}
}
class color extends JPanel
{
public color()
{
JCheckBox c1 = new JCheckBox("red");
add(c1);
JCheckBox c2 = new JCheckBox("green");
add(c2);
JCheckBox c3 = new JCheckBox("blue");
add(c3);
}
}

OUTPUT

0 comments:

Post a Comment