Java examples for Swing:JTextField
To make JTextField read only or non editable use, void setEditable(boolean editable) method with false argument.
import javax.swing.JTextField; public class Main { public void init() { JTextField field = new JTextField("Read Only JTextField"); field.setEditable(false);/* w w w. ja va 2s . com*/ // field.setEditable(true); } }