How to disable the default behavior of CONTROL+PAGE_UP and CONTROL+PAGE_DOWN of a JTabbedPane
?
Asked
Active
Viewed 301 times
2

Andrew Thompson
- 168,117
- 40
- 217
- 433
2 Answers
3
KeyBindings are used for internall commands (for Swing JComponents)
see list of KeyBindings by @camickr
- get
ctrl PAGE_DOWN
/ctrl PAGE_UP
(implemented KeyBindings in API for JTabbedPane) and to set to null

mKorbel
- 109,525
- 20
- 134
- 319
2
The following code disables the usual behavior
JTabbedPane jTabbedPane = new JTabbedPane();
KeyStroke ctrlTab = KeyStroke.getKeyStroke("ctrl PAGE_DOWN");
KeyStroke ctrlShiftTab = KeyStroke.getKeyStroke("ctrl PAGE_UP");
InputMap inputMap = jTabbedPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(ctrlTab, "none");
inputMap.put(ctrlShiftTab, "none");
Here is an example for Switching tab using Ctrl + Tab

vels4j
- 11,208
- 5
- 38
- 63