package now;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Now extends JFrame {
JLabel FirstName;
JTextField jtfFirstName;
JLabel LastName;
JTextField jtfLastName;
JLabel Age;
JTextField jtfAge;
public Now(){
//Set FlowLayout
setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
//Add labels and text fields to the frame
add (new JLabel("First Name"));
add (new JTextField(15));
add (new JLabel("Last Name"));
add (new JTextField(15));
add (new JLabel("Age"));
add (new JTextField(2));
JButton welcome = new JButton ("CLICK HERE");
//Create Panel to hold button
JPanel panel = new JPanel();
panel.add(welcome);
event e = new event();
welcome.addActionListener(e);
}
public class event implements ActionListener{
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(null, "Welcome, " );
}
}
public static void main(String[] args) {
Now frame = new Now();
frame.setTitle("Welcome!");
frame.setSize(200, 250);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
I am trying to have a user input their first name, last name, and age and when they click the JButton I want it to say "Welcome, First Name & Last name!!! Any assistance would be greatly appreciate it.
I know I need a string within this area
public class event implements ActionListener{
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(null, "Welcome, " );
I do not know how to set it up.