I'm working on a complex desktop app with multiple tabbed panes for workflow, each one stuffed with different buttons, labels and other UI elements. Each of them require a mnemonic defined, and these often come into conflict because of running out of letters to define.
I have noticed that on Windows, if there is the same mnemonic defined for two controls, then pressing it will cycle between them, and they activate upon releasing the key. With Swing, the mnemonics simply won't activate if you define 2 of them with the same key.
Is there a workaround for this?
My suggestion would be to use a KeyListener
and then differentiate the actions based on what tab is showing.
Pseudo-code:
public void keyPressed(KeyEvent e){
//assuming 'O' activates Open button on two different tabs
if(key == 'O'){
if(activeTab == tab1)
doStuff1();
else if(activeTab == tab2)
doStuff2();
}
}
You can find a way to make it work in real code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With