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());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300, 300);
setVisible(true);
}
public static void main(String[] args) 
{
new JTextFieldDemo();
}
}

Output

pic

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

Comment