JTextField textField = new JTextField(); textField.setBackground(Color.WHITE);
JTextField textField = new JTextField(); textField.setBackground(Color.WHITE); textField.setEnabled(false); textField.setBackground(Color.RED);This sets the background color of the text field to white initially, and then changes it to red when the text field is disabled. These examples use the java.awt.Color class, which is part of the Java Standard Library. The javax.swing package is part of the Java Runtime Environment, which means it is included with any Java installation.