开发者

Is it possible to gain Tab Focus of a JTable Header Cell?

开发者 https://www.devze.com 2023-03-27 03:29 出处:网络
I have a JTable that has a table header which contains a JPanel with a JLabel with a mouse listener on the JLabel.When the JLabel is clicked a dialog is shown.I\'m trying to trigger this JLabel in the

I have a JTable that has a table header which contains a JPanel with a JLabel with a mouse listener on the JLabel. When the JLabel is clicked a dialog is shown. I'm trying to trigger this JLabel in the JTable heading without a mouse. In order to trigger t开发者_如何转开发his JLabel without a mouse, I need the focus to be on the JTable heading (that is, I need the JTable heading to be in the focus traversal policy). Does anybody know if its possible to Tab to a JTable heading cell?


table.getTableHeader().setFocusable(true)

alternatively, you might add the action "triggered by the JLabel" to the table's action map and bind it to a keyStroke in the table's when_ancestor inputMap


Focus can be placed on the TableHeader by using F8 when focus is on the table.

You can then use the right/left keys to move between the header cells.

You use the Tab key to place focus back on the table.

0

精彩评论

暂无评论...
验证码 换一张
取 消