Java program to create an input field on a frame
Codeaft.java
import javax.swing.*;
import java.awt.FlowLayout;
class Codeaft
{
    public static void main(String args[])
    {
        JPanel p=new JPanel();
        FlowLayout fl=new FlowLayout();
        p.setLayout(fl);
        JLabel l=new JLabel("Enter the name ");
        JTextField tf=new JTextField(10);
        p.add(l);
        p.add(tf);
        JFrame f=new JFrame("Frame");
        f.setContentPane(p);
        f.setSize(300,300);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
    }
}
Output
codeaft@codeaft:~$ javac Codeaft.java
codeaft@codeaft:~$ java Codeaft
Comments and Reactions