Tabpane with 3 tabs

import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JTabbedPane;

public class TabpaneDemo1 extends JApplet {
	JTabbedPane tb;
	Panel1 p1;
	Panel2 p2;
	Panel3 p3;

	@Override
	public void init() {
		tb = new JTabbedPane();
		getContentPane().add(tb);
		p1 = new Panel1();
		p2 = new Panel2();
		p3 = new Panel3();
		tb.addTab("Cities", new ImageIcon("D:\\SwingWorkSpace\\" +
				"Project1\\src\\borderdemo\\eyeRoll.gif"), p1);
		tb.addTab("Color", p2);
		tb.addTab("Fruit", p3);
	}
}

Download

Panel1.java

import javax.swing.JButton;
import javax.swing.JPanel;
public class Panel1 extends JPanel 
{
	public Panel1() {

	    JButton b1 = new JButton("New Delhi");
	    add(b1);
	    JButton b2 = new JButton("Noida");
	    add(b2);
	    JButton b3 = new JButton("Pune");
	    add(b3);
	    JButton b4 = new JButton("Kolkata");
	    add(b4);
	  }
}

Download

Panel2.java

import javax.swing.JCheckBox;
import javax.swing.JPanel;
public class Panel2 extends JPanel
{
	public Panel2() {

	    JCheckBox cb1 = new JCheckBox("Black");
	    add(cb1);
	    JCheckBox cb2 = new JCheckBox("Grey");
	    add(cb2);
	    JCheckBox cb3 = new JCheckBox("Blue");
	    add(cb3);
	  }

}

Download

Panel3.java

import javax.swing.JComboBox;
import javax.swing.JPanel;
public class Panel3 extends JPanel 
{
	public Panel3() {

	    JComboBox jcb = new JComboBox();
	    jcb.addItem("Banana");
	    jcb.addItem("Applet");
	    jcb.addItem("Orange");
	    jcb.addItem("PineApple");
	    add(jcb);
	  }
}

Download

Tabpane in Java

Simple Table with fixed value in Swing


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code