Here you can find the source of setEnabled(JTextField textField, boolean enabled)
Parameter | Description |
---|---|
textField | Swing JTextField object |
enabled | Flag to indicate whether to enable or disable the object |
public static void setEnabled(JTextField textField, boolean enabled)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import javax.swing.JTextField; import javax.swing.UIManager; public class Main { /**//from www . ja va 2 s .co m * Method to enable/disable a Swing JTextField object * * @param textField Swing JTextField object * @param enabled Flag to indicate whether to enable or disable the object */ public static void setEnabled(JTextField textField, boolean enabled) { if (enabled) { textField.setEnabled(true); textField.setBackground(Color.WHITE); } else { textField.setEnabled(false); textField.setBackground(UIManager.getColor("Panel.background")); } } }