TabbedPane Sample
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
public class TabSample {
static void addIt(JTabbedPane tabbedPane, String text) {
JLabel label = new JLabel(text);
JButton button = new JButton(text);
JPanel panel = new JPanel();
panel.add(label);
panel.add(button);
tabbedPane.addTab(text, panel);
}
public static void main(String args[]) {
JFrame f = new JFrame("JTabbedPane Sample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = f.getContentPane();
JTabbedPane tabbedPane = new JTabbedPane();
addIt(tabbedPane, "Tab One");
addIt(tabbedPane, "Tab Two");
addIt(tabbedPane, "Tab Three");
addIt(tabbedPane, "Tab Four");
addIt(tabbedPane, "Tab Five");
content.add(tabbedPane, BorderLayout.CENTER);
f.setSize(300, 200);
f.setVisible(true);
}
}
Related examples in the same category