To change the color of a disabled background, try the following:
UIManager.put("TextField.disabledBackground", Color.GRAY);
You can change the color of the disabled text with setDisabledTextColor , i.e .:
textField.setDisabledTextColor(Color.GRAY);
EDIT: Enable SSCCE
import java.awt.Color;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
public class TestDisabledTextField {
public static void main(String[] args) {
UIManager.put("TextField.disabledBackground", Color.YELLOW);
JTextField textField = new JTextField("Disabled text field", 15);
textField.setEnabled(false);
textField.setDisabledTextColor(Color.RED);
JPanel panel = new JPanel();
panel.add(textField);
JOptionPane.showMessageDialog(null, panel);
}
}
source
share