I have a JButton that is constructed using an Action and this action has a name that is contains html.
I then go about setting the mnemonic on the JButton by first parsing out html to get the first character in the name.
For example, the JButton name might be "<html>Test<br>Button</html>", so after parsing the html the mnemonic key should be “T”.
So now when the JButton is rendered I can push alt-T to activate the button, however the underline mnemonic indicator on the T is not present.
Would anyone know a way to get this to occur?
It is unclear to me what you mean by “setting the mnemomic on the JButton by parsing html”. The mnemonic can be set on a JButton by calling the method
setMnemonicin the JButton class. I tried below piece of code and when I pressAlt+PI get the messageI am pressedprinted in the console.Also see the section How to Use HTML in Swing Components in the Java tutorial.