Summary
JCheckBoxやJComboBoxなどのコンポーネントが無効な状態になった場合の文字色を変更します。
Screenshot

Advertisement
Source Code Examples
UIManager.put("CheckBox.disabledText", Color.RED);
JCheckBox cbx1 = new JCheckBox("default", true);
JCheckBox cbx2 = new JCheckBox("<html>html <span style='color:red'>tag");
View in GitHub: Java, KotlinDescription
JCheckBoxUIManager.put("CheckBox.disabledText", Color.RED)MetalLookAndFeelでのみ有効
JCheckBox+htmlJDK 1.7.0で以下の動作は修正されて、無効化でHTML文字列もグレーになる<html>タグを使った場合、文字色は常に不変でisEnabled()の状態に依存しない(Bug ID: 4740519 HTML JLabel not greyed out on setEnabled(false))を利用
JComboBoxUIManager.put("ComboBox.disabledForeground", Color.GREEN);
JComboBox+html- レンダラーで文字色を変更
JComboBox(Editable)EditorComponentを取得して、editor.setDisabledTextColor(Color.PINK);を設定
JLabelUIManager.put("Label.disabledForeground", Color.ORANGE);
JButtonUIManager.put("Button.disabledText", Color.YELLOW)MetalLookAndFeelでのみ反映
Reference
- [JDK-4740519] HTML JLabel not greyed out on setEnabled(false) - Java Bug System
- Swing - How to disable a JCheckBox and leave the text the original color?
- [JDK-4783068] Components with HTML text should gray out the text when disabled - Java Bug System
- Htmlを使ったJLabelとJEditorPaneの無効化
- [JDK-7093691] Nimbus LAF: disabled JComboBox using renderer has bad font color - Java Bug System
- JButtonが無効な状態でのhtmlテキスト色を変更する
