Java examples for Swing:JTextField
Various ways to Create JTextField
import java.awt.FlowLayout; import javax.swing.JApplet; import javax.swing.JTextField; public class Main { public void init(){ /*/*from w w w . j a v a 2 s . c o m*/ * JTextField() will create new empty JTextField. */ JTextField field1 = new JTextField(); /* * To create new JTextField with default text, use JTextField(String text) */ JTextField field2 = new JTextField("JTextField Default Text"); /* * To create new JTextField with specified number of columns, use JTextField(int columns) */ JTextField field3 = new JTextField(10); /* * To create new JTextField with default text and columns use * JTextField(String text, int columns) */ JTextField field4 = new JTextField("JTextField Default Text", 20); } }