Create Read Only JTextField - Java Swing

Java examples for Swing:JTextField

Introduction

To make JTextField read only or non editable use, void setEditable(boolean editable) method with false argument.

Demo Code

 
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);


  }

}

Related Tutorials