JTextField Class

JTextField class is used to create a text box and takes single line of text as input. It is most widely used text component. JTextField having three constructors, such as:

Let?s see an example for displaying an image on the button.

JTextField(int columns)
JTextField(String str, int columns)
JTextField(String str)
Let?s see an example using JTextField class:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class JTextFieldDemo extends JFrame 
public JTextFieldDemo() 
JTextField jf = new JTextField(20);	              //creating JTextField. 
add(jf);				//adding JTextField to frame. 
setLayout(new FlowLayout());
setSize(300, 300);
public static void main(String[] args) 
new JTextFieldDemo();



Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology, BBSR
Call to: 9439202111  |  9658317757  |  0674-2361252