Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put mnemonic under the second instance of a Character (Java-Swing)?

I have a JButton named button1 with text "Alter Today".

I want to set a mnemonic under 'T' in the word 'Today' of this button (that is second instance of 't' or 'T' in 'Alter Today').

When I am trying to do:

button1.setMnemonic(6);

I am not able to see underlined 'T'.

When I am doing:

button1.setMnemonic('T');

it is still underlining 't' in the word 'Alter'.

How to do it?

like image 241
Vikram Avatar asked Dec 27 '22 17:12

Vikram


2 Answers

Try this -

bt.setMnemonic('T');

bt.setDisplayedMnemonicIndex(6);

Hope that helps :)

like image 126
sgibly Avatar answered Jan 28 '23 14:01

sgibly


button.setDisplayedMnemonicIndex(...);
like image 41
camickr Avatar answered Jan 28 '23 14:01

camickr