The work around
A less elegant solution, you could try adding a key listener to override the default "ctrl + a" behavior by implementing a keyPressed method (please note that the following sample does not disallow "ctrl + a" just adds support for "meta + a"):
@Override
public void keyPressed(final KeyEvent e) {
// Get the default toolkit shortcut mask ("meta" for OSX).
int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
// You could also check modifiers against KeyEvent.META_MASK...
if (e.getModifiers() == keyMask && e.getKeyCode() == KeyEvent.VK_A) {
// Select everything (assumes member of child text component class).
this.selectAll();
// We handled this keystroke, 'a' will be ignored by underlying text component.
e.consume();
}
}
A better alternative would be to use inputMaps (see comment by uudashr below).
Thoughts on the root cause
Unfortunately, as the class name suggests the look and feel (or LAF) is a combination of appearance i.e. look, as well as "system behavior", i.e. feel. If you dig around the substance source, the SubstanceLookAndFeel overrides the BasicLookAndFeel that ships with swing. It looks as though it is within the BasicLookAndFeel the offending behavior is set in initComponentDefaults. You should be able to get the UIDefaults from the LAF by calling getDefaults().
Problems from here are:
- "System behaviors" which you wish to change are intermingled with appearance settings you wish to leave untouched.
- I have also been unable to find any easy way to inject these defaults into substance at the LAF level... Anyone with other ideas on this?