Search code examples
javaswingjtabbedpanefocusable

It is possible to make just some tabs focusable (JTabbedPane)?


It is possible to make just some tabs focusable, for instance the first 3 of 5 tabs? So that when changing tabs with the left - right keys, the non-focusable ones to be skipped (to be displayed only by mouse clicks).

Thanks!


Solution

  • All Swing components use Actions to handle key events. So you can replace the existing action with a custom Action of your own.

    Check out Key Bindings to see the Actions that are defined for a tabbed pane.

    You may also find Wrapping Actions and Table Tabbing helpful as they show how you can reuse existing Actions when customizing behaviour.