I have a query. I have the following java code and I want the button to greet me to capture the name that the user types and when I click on the button, I will show it to me in the Jframe.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Ventanita extends JFrame implements ActionListener {
public Ventanita() {
jPanel.add(label);
jPanel.add(jTextField);
jPanel.add(jButton);
jPanel.add(label1);
jPanel.add(label2);
add(jPanel);
}
public static void main(String[] args) {
JFrame x = new Ventanita();
x.setSize(400, 400);
x.setVisible(true);
x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
JLabel label = new JLabel("Nombre");
JTextField jTextField = new JTextField("10");
JButton jButton = new JButton("Saluda");
JLabel label1 = new JLabel("Hola");
JLabel label2 = new JLabel(" ");
JPanel jPanel = new JPanel();
@Override
public void actionPerformed(ActionEvent ae) {
}
}