Example usage for javax.swing JTabbedPane getMnemonicAt

List of usage examples for javax.swing JTabbedPane getMnemonicAt

Introduction

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

Prototype

public int getMnemonicAt(int tabIndex) 

Source Link

Document

Returns the keyboard mnemonic for accessing the specified tab.

Usage

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  ww.  ja va  2s . co m*/
}

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;/*from  ww w.  ja va2  s  . 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);
}