Mnemonics are those underlined letters that you see in labels and buttons that when activated via the ALT key + the letter, will activate that label/button.

However, when a JTable is included in the user interface and has editing capabilities enabled, you may be surprised that instead of activing a button by pressing ALT + key on the keyboard, the JTable activates editing mode.

How to fix it then? You need to override the processKeyBinding() method of the JTable class. Do it like this

This solution was from a forum called and fixed this mnemonic problem when a JTable with cell editors is present in the same user interface area.

Do you know what mnemonics are? Those are short underlines below an alphabet character usually found on labels. Usually when you press the key ALT together with the said letter, if the mnemonic is inside a button, the button gets pushed, the same result as when you click on that same button using a mouse. To activate this, we use the character & (ampersand) beside the letter. Simple as that. In Visual Studio, just go to the control’s properties and look for the Text property.

But what if we set a mnemonic to a Label so that when the key combination is activated, the focus goes to a TextBox. You do the same thing you do with the button’s label. Add an & character beside the letter. To link the Label and the TextBox, the TabIndex of the Label must be – 1 (minus 1) than the TabIndex of the TextBox. This is how it works in Visual Studio unlike Java where you use a method to set the component that the Label‘s mnemonic will focus on. You can find TabIndex part within the properties of the Control.

Related Posts Plugin for WordPress, Blogger...