Example usage for javax.swing JTabbedPane JTabbedPane

List of usage examples for javax.swing JTabbedPane JTabbedPane

Introduction

In this page you can find the example usage for javax.swing JTabbedPane JTabbedPane.

Prototype

public JTabbedPane() 

Source Link

Document

Creates an empty TabbedPane with a default tab placement of JTabbedPane.TOP.

Usage

From source file:SimpleTab.java

public SimpleTab() {
    super("JTabbedPane");
    setSize(200, 200);//ww w.j a v a 2  s .  c om
    Container contents = getContentPane();
    jtp = new JTabbedPane();
    jtp.addTab("Tab1", new JLabel("This is Tab One"));
    jtp.addTab("Tab2", new JButton("This is Tab Two"));
    jtp.addTab("Tab3", new JCheckBox("This is Tab Three"));
    contents.add(jtp);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setVisible(true);
}

From source file:TooManyTabs.java

public TooManyTabs() {
    super("Too Many Tabs Test");
    setSize(200, 200);//from  w  w  w  . java 2s. c  o  m
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    Container contents = getContentPane();

    JTabbedPane wrap = new JTabbedPane();
    JTabbedPane scroll = new JTabbedPane();
    scroll.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    for (int i = 1; i < 24; i++) {
        String tab = "Tab #" + i;
        wrap.addTab(tab, new JLabel(tab));
        scroll.addTab(tab, new JLabel(tab));
    }
    JTabbedPane top = new JTabbedPane(JTabbedPane.RIGHT);
    top.addTab("Wrap Tabs", wrap);
    top.addTab("Scroll Tabs", scroll);
    contents.add(top);

    setVisible(true);
}

From source file:Main.java

public JComponent makeUI() {
    UIManager.put("TabbedPane.tabInsets", new Insets(2, 2, 2, 50));
    final JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("A", new JPanel());

    JPanel p = new JPanel(new BorderLayout());
    p.add(new JLayer<JTabbedPane>(tabbedPane, new CloseableTabbedPaneLayerUI()));
    p.add(new JButton(new AbstractAction("add tab") {
        @Override/*from  w  ww  . ja  v  a  2 s  .  c  o  m*/
        public void actionPerformed(ActionEvent e) {
            tabbedPane.addTab("test", new JPanel());
        }
    }), BorderLayout.SOUTH);
    return p;
}

From source file:MainClass.java

private void makeGUI() {

    JTabbedPane jtp = new JTabbedPane();
    jtp.addTab("Cities", new CitiesPanel());
    jtp.addTab("Colors", new ColorsPanel());
    jtp.addTab("Flavors", new FlavorsPanel());
    add(jtp);//from w  ww  .j av  a2  s. c  o m
}

From source file:Main.java

public Main() {
    super("Browser");
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JMenuBar mb = new JMenuBar();
    JMenu mFile = new JMenu("File");
    JMenuItem mi = new JMenuItem("Add Tab");
    ActionListener addTabl = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            addTab();/*from  w  ww . j a va2 s  .  c o  m*/
        }
    };
    mi.addActionListener(addTabl);
    mFile.add(mi);
    mb.add(mFile);
    setJMenuBar(mb);

    JPanel pnlURL = new JPanel();
    tp = new JTabbedPane();
    addTab();
    add(tp, BorderLayout.CENTER);
    setSize(300, 300);
    setVisible(true);
}

From source file:Main.java

public Main() {
    setSize(500, 500);/*from   ww w.j ava2s. c om*/
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setLayout(new GridLayout(0, 1));
    JPanel buttonPanel = new JPanel();

    JButton addButton = new JButton("add");
    addButton.addActionListener(e -> addElementToArrayList());
    JButton removeButton = new JButton("remove");
    removeButton.addActionListener(e -> removeElementFromArrayList());

    tabbedPane = new JTabbedPane();
    tabbedPaneMouseListener = (new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e)) {
                if (e.getClickCount() == 1) {
                    System.out.println("Do Something");
                }
            }
        }
    });
    tabbedPane.addMouseListener(tabbedPaneMouseListener);

    buttonPanel.add(addButton);
    buttonPanel.add(removeButton);
    add(buttonPanel);
    this.add(tabbedPane);
}

From source file:Main.java

public Main() {
    Box box1 = Box.createVerticalBox();
    for (int i = 1; i <= 100; i++) {
        box1.add(new JLabel("This is Label #" + i));
    }/*from   w  w  w  .j  a va  2 s.c o  m*/

    Box box2 = Box.createVerticalBox();
    for (int i = 1; i <= 100; i++) {
        box2.add(new JLabel("This is Label #" + i));
    }

    JPanel boxPanel1 = new JPanel();
    JPanel boxPanel2 = new JPanel();
    boxPanel1.add(box1);
    boxPanel2.add(box2);
    JScrollPane panel1Scroll = new JScrollPane(boxPanel1);
    JScrollPane panel2Scroll = new JScrollPane(boxPanel2);

    panelTab1 = new JPanel(new BorderLayout());
    panelTab2 = new JPanel(new BorderLayout());
    panelTab1.add(panel1Scroll);
    panelTab2.add(panel2Scroll);

    tabbedPane = new JTabbedPane();
    tabbedPane.add(panelTab1, "Panel 1");
    tabbedPane.add(panelTab2, "Panel 2");

    JFrame frame = new JFrame();
    frame.add(tabbedPane);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

From source file:id.aas.apps.mvc.view.frameChart.java

public frameChart() throws SQLException {
    super("Chart");

    tabPane = new JTabbedPane();
    panel1 = new JPanel();
    tabPane.addTab("Grafik Pendepatan dan Piutang", null, panel1, "Panel Pertama");

    panel2 = new JPanel();
    tabPane.addTab("Grafik Pengguna Layanan UMLLaundry", null, panel2, "Panel Kedua");

    getContentPane().add(tabPane);/*  w  w  w  . j a v  a  2  s .co m*/
    setChartBar();
    setChartPie();
    setSize(700, 500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
    //        setVisible(true);
}

From source file:AddButtonToTabBar.java

public AddButtonToTabBar() {
    super("Browser");
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JMenuBar mb = new JMenuBar();
    JMenu mFile = new JMenu("File");
    JMenuItem mi = new JMenuItem("Add Tab");
    ActionListener addTabl = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            addTab();//w  w  w.j  av  a 2  s .com
        }
    };
    mi.addActionListener(addTabl);
    mFile.add(mi);
    mb.add(mFile);
    setJMenuBar(mb);

    JPanel pnlURL = new JPanel();
    tp = new JTabbedPane();
    addTab();
    getContentPane().add(tp, BorderLayout.CENTER);

    lblStatus = new JLabel(" ");
    getContentPane().add(lblStatus, BorderLayout.SOUTH);

    setSize(300, 300);
    setVisible(true);
}

From source file:Main.java

public Main() {
    setSize(450, 350);//w ww. j  a  v a  2  s.  co  m
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().add(textfield, BorderLayout.SOUTH);

    JMenuBar mbar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.add(new JCheckBoxMenuItem("Check Me"));
    menu.addSeparator();
    JMenuItem item = new JMenuItem("Exit");
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    menu.add(item);
    mbar.add(menu);
    setJMenuBar(mbar);

    JTabbedPane tabbedPane = new JTabbedPane();

    tabbedPane.addTab("Button", new TabIcon(), new JButton(""), "Click here for Button demo");
}