Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>The work around</strong></p> <p>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"):</p> <pre><code>@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 &amp;&amp; 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(); } } </code></pre> <p>A better alternative would be to use inputMaps (see comment by uudashr below).</p> <hr> <p><strong>Thoughts on the root cause</strong></p> <p>Unfortunately, as the class name suggests the look and feel (or <em>LAF</em>) is a combination of appearance i.e. <em>look</em>, as well as "system behavior", i.e. <em>feel</em>. If you dig around the substance source, the <a href="https://substance.dev.java.net/source/browse/substance/src/org/pushingpixels/substance/api/SubstanceLookAndFeel.java?rev=1.3&amp;view=markup" rel="nofollow noreferrer">SubstanceLookAndFeel</a> overrides the <a href="http://kickjava.com/src/javax/swing/plaf/basic/BasicLookAndFeel.java.htm" rel="nofollow noreferrer">BasicLookAndFeel</a> 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().</p> <p>Problems from here are: </p> <ul> <li>"System behaviors" which you wish to change are intermingled with appearance settings you wish to leave untouched.</li> <li>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?</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload