Create and use Tabbed Panes - Java Swing

Java examples for Swing:JTabbedPane

Description

Create and use Tabbed Panes

Demo Code

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

public class Main extends JFrame {

  public Main() {
    super("Tabbed Panes");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setSize(480, 218);// w ww  . ja  va  2s. co m
    JPanel mainSettings = new JPanel();
    JPanel advancedSettings = new JPanel();
    JPanel privacySettings = new JPanel();
    JPanel emailSettings = new JPanel();
    JPanel securitySettings = new JPanel();
    JTabbedPane tabs = new JTabbedPane();
    tabs.addTab("Main", mainSettings);
    tabs.addTab("Advanced", advancedSettings);
    tabs.addTab("Privacy", privacySettings);
    tabs.addTab("E-mail", emailSettings);
    tabs.addTab("Security", securitySettings);
    add(tabs);
    setVisible(true);
  }

  public static void main(String[] arguments) {
    Main frame = new Main();
  }
}

Related Tutorials