
give me the code of input box in core java.

import javax.swing.*;
import java.awt.event.*;
class TextFieldExample
{
public static void main(String[] args)
{
JFrame f=new JFrame();
final JTextField text=new JTextField(20);
JButton b=new JButton("Get");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
String str=text.getText();
JOptionPane.showMessageDialog(null,"You have entered: "+str);
}
});
text.setBounds(10,10,150,20);
b.setBounds(10,30,100,20);
f.setLayout(null);
f.add(text);
f.add(b);
f.setVisible(true);
f.setSize(300,100);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.