I am currently working on the accessibility of a swing based GUI. I
have a number of GUI elements which have a titledBorder and I am
looking for a way to set up a mnemonic and/or a keyboard shortcut to
bring the keyboard focus to that element. I know how to achieve a
similar result with a jlabel, setLabelFor, and setDisplayedMnemonic,
but the titledBorder looks better, requires less code, and it also
automatically sets the accessibleName property to the title.
any clue?
Andrey Kuznetsov - 27 Jul 2006 07:48 GMT
>I am currently working on the accessibility of a swing based GUI. I
> have a number of GUI elements which have a titledBorder and I am
[quoted text clipped - 5 lines]
>
> any clue?
since TitledBorder is not a Component you can't do it directly,
but you may try to hack it.
You need 2 things:
1) to show mnemonic char in the TitledBorder - see in the source of
JLabel/LabelUI how to do it
2) move focus to your component if mnemonic key was pressed - you can do it
with ActionMap/InputMap
HTH
Andrey

Signature
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities