❮ Previous Next ❯

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

❮ Previous Next ❯



  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved