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(); } }
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc