Create text field using JTextField

Source code below will show you, how to create text field in java using JTextField class.

**************************************************************************
COMPLETE SOURCE CODE FOR : CreateTextFieldUsingJTextField.java
**************************************************************************


import javax.swing.JTextField;
import javax.swing.JFrame;

public class CreateTextFieldUsingJTextField
{
public static void main(String[]args)
{
//Create a text field with no initial text in it
JTextField textField=new JTextField();

//Create a JFrame that will be use to place created text field
JFrame frame=new JFrame("Create text field using JTextField");

//add created JTextField into JFrame
frame.add(textField);

//set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//set JFrame size
//WIDTH = 400 pixels
//HEIGHT = 65 pixels
frame.setSize(400,65);

//make JFrame visible. So we can see it
frame.setVisible(true);
}
}


**************************************************************************
JUST COMPILE AND EXECUTE IT
**************************************************************************

RELAXING NATURE VIDEO