How to disable CONTROL+PAGE_UP of a JTabbedPane?

六月ゝ 毕业季﹏ 提交于 2019-12-11 04:02:06

问题


How to disable the default behavior of CONTROL+PAGE_UP and CONTROL+PAGE_DOWN of a JTabbedPane?


回答1:


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




回答2:


  • 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


来源:https://stackoverflow.com/questions/16558672/how-to-disable-controlpage-up-of-a-jtabbedpane

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!