Hello all. I am having an error when running my program. The compiler doesnt catch any errors but when I run the applet it never seems to load all the way. Any guesses?
here is my code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JGreet extends JApplet implements ActionListener
{
Container con = getContentPane();
JLabel greeting = new JLabel("Greetings");
JLabel firstLabel = new
JLabel("Please enter your first name:");
JLabel lastLabel = new
JLabel("Please enter your last name:");
JTextField firstField = new JTextField ("", 10);
JTextField lastField = new JTextField ("", 10);
JButton viewButton = new JButton("View Greeting");
FlowLayout flow = new FlowLayout();
public void init()
{
con.setLayout(flow);
con.add(greeting);
con.add(firstLabel);
con.add(firstField);
con.add(lastLabel);
con.add(lastField);
con.add(viewButton);
firstField.requestFocus();
}
public void actionPerformed(ActionEvent thisEvent)
{
String firstName = firstField.getText();
String lastName = lastField.getText();
greeting.setText("How are you, " + firstName + " " +
lastName + "?");
}
}