Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This experiment suggests one answer is 'Use a PLAF that is not Metal'.</p> <p><img src="https://i.stack.imgur.com/89avK.png" alt="Look Of Disabled Buttons"></p> <pre><code>import java.awt.*; import javax.swing.*; class LookOfDisabledButton { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JPanel gui = new JPanel(new BorderLayout(3,3)); JPanel pEnabled = new JPanel(new GridLayout(1,0,2,2)); pEnabled.setBackground(Color.green); gui.add(pEnabled, BorderLayout.NORTH); JPanel pDisabled = new JPanel(new GridLayout(1,0,2,2)); pDisabled.setBackground(Color.red); gui.add(pDisabled, BorderLayout.SOUTH); UIManager.LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels(); for (UIManager.LookAndFeelInfo plafInfo : plafs) { try { UIManager.setLookAndFeel(plafInfo.getClassName()); JButton bEnabled = new JButton(plafInfo.getName()); pEnabled.add(bEnabled); JButton bDisabled = new JButton(plafInfo.getName()); bDisabled.setEnabled(false); pDisabled.add(bDisabled); } catch(Exception e) { e.printStackTrace(); } } JOptionPane.showMessageDialog(null, gui); } }); } } </code></pre> <hr> <p>Alternately, adjust the values in the <code>UIManager</code>.</p> <p><img src="https://i.stack.imgur.com/zHjBJ.png" alt="UIManager tweak"></p> <pre><code>import java.awt.*; import javax.swing.*; class LookOfDisabledButton { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JPanel gui = new JPanel(new BorderLayout(3,3)); JPanel pEnabled = new JPanel(new GridLayout(1,0,2,2)); pEnabled.setBackground(Color.green); gui.add(pEnabled, BorderLayout.NORTH); JPanel pDisabled = new JPanel(new GridLayout(1,0,2,2)); pDisabled.setBackground(Color.red); gui.add(pDisabled, BorderLayout.SOUTH); // tweak the Color of the Metal disabled button UIManager.put("Button.disabledText", new Color(40,40,255)); UIManager.LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels(); for (UIManager.LookAndFeelInfo plafInfo : plafs) { try { UIManager.setLookAndFeel(plafInfo.getClassName()); JButton bEnabled = new JButton(plafInfo.getName()); pEnabled.add(bEnabled); JButton bDisabled = new JButton(plafInfo.getName()); bDisabled.setEnabled(false); pDisabled.add(bDisabled); } catch(Exception e) { e.printStackTrace(); } } JOptionPane.showMessageDialog(null, gui); } }); } } </code></pre> <hr> <p>As pointed out by kleopatra..</p> <blockquote> <p>it's not a solution but might be a pointer to the direction to search for a solution </p> </blockquote> <p>Where 'it' is my answer. In fact, I suspect she hit upon the real cause with the comment:</p> <blockquote> <p>guessing only: here it's due to violating the one-plaf-only rule.</p> </blockquote> <p>I second that guess.</p>
 

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