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:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    pane.addTab("Tab Label", new JButton("Button"));
    // Get index of the new tab
    int index = pane.getTabCount() - 1;

    // Determine whether the tab is enabled
    boolean enabled = pane.isEnabledAt(index);

    // Disable the tab
    pane.setEnabledAt(index, false);//from  ww w. j a  v a 2  s  .  com
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    JButton component = new JButton("button");

    String tooltip = "Tool Tip Text";
    pane.addTab("label", new ImageIcon("icon.png"), component, tooltip);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    JButton component = new JButton("button");

    int index = 1;
    pane.insertTab("label", new ImageIcon("icon.png"), component, "tooltip", index);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    pane.setForeground(Color.YELLOW);
    pane.setBackground(Color.MAGENTA);
    String label = "Tab Label";
    pane.addTab(label, new JButton("Button"));

    int index = pane.getTabCount() - 1;

    pane.setForegroundAt(index, Color.ORANGE);
    pane.setBackgroundAt(index, Color.GREEN);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    int count = pane.getTabCount();
    for (int i = 0; i < count; i++) {
        String label = pane.getTitleAt(i);
        Icon icon = pane.getIconAt(i);
        String tooltip = pane.getToolTipTextAt(i);
        boolean enabled = pane.isEnabledAt(i);
        int keycode = pane.getMnemonicAt(i);
        Component comp = pane.getComponentAt(i);
    }// w w w  .j  a  v a  2  s  .  co m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    pane.addTab("Tab Label", new JButton("button"));
    int index = pane.getTabCount() - 1;

    int keycode = KeyEvent.VK_L;
    pane.setMnemonicAt(index, keycode);/*from   w ww  .j a  v  a  2 s .c o m*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    JButton component = new JButton("button");

    Icon icon = new ImageIcon("icon.gif");
    pane.addTab("label", icon, component);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JTabbedPane pane = new JTabbedPane();

    pane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            JTabbedPane pane = (JTabbedPane) evt.getSource();

            int sel = pane.getSelectedIndex();
            System.out.println(sel);
        }//  w w w .j  av  a2  s. c  o m
    });
}

From source file:Main.java

public static void main(String[] args) {
    JTabbedPane tp = new JTabbedPane();
    tp.addTab("Dates", new JPanel());
    tp.addTab("Deliveries", new JPanel());
    tp.addTab("Exports", new JPanel());

    tp.setTabComponentAt(0, new JLabel("Dates"));
    tp.setTabComponentAt(1, new JLabel("Deliveries"));
    tp.setTabComponentAt(2, new JLabel("Exports"));

    JFrame frame = new JFrame("Testing");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(tp);/*from  w ww  .  j  a  v a 2  s . c  o  m*/
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    int src = pane.getTabCount() - 1;
    int dst = 0;/*  www.java 2s. c om*/

    Component comp = pane.getComponentAt(src);
    String label = pane.getTitleAt(src);
    Icon icon = pane.getIconAt(src);
    Icon iconDis = pane.getDisabledIconAt(src);
    String tooltip = pane.getToolTipTextAt(src);
    boolean enabled = pane.isEnabledAt(src);
    int keycode = pane.getMnemonicAt(src);
    int mnemonicLoc = pane.getDisplayedMnemonicIndexAt(src);
    Color fg = pane.getForegroundAt(src);
    Color bg = pane.getBackgroundAt(src);

    pane.remove(src);

    pane.insertTab(label, icon, comp, tooltip, dst);

    pane.setDisabledIconAt(dst, iconDis);
    pane.setEnabledAt(dst, enabled);
    pane.setMnemonicAt(dst, keycode);
    pane.setDisplayedMnemonicIndexAt(dst, mnemonicLoc);
    pane.setForegroundAt(dst, fg);
    pane.setBackgroundAt(dst, bg);
}