Setting a mnemonic on a tab allows the tab to be selected with a keystroke. For example, if the mnemonic for a tab were the key L, then typing ALT-L (on Windows) would select the tab.

    // Create a tabbed pane
    JTabbedPane pane = new JTabbedPane();
    
    // Add a tab
    pane.addTab("Tab Label", component);
    
    // Get index of the new tab
    int index = pane.getTabCount()-1;
    
    // Set the mnemonic; on some look and feels, the L in the label will be underlined
    int keycode = KeyEvent.VK_L;
    pane.setMnemonicAt(index, keycode);

 

Related Examples

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
猜你喜欢
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案