Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Applet not Initialized

807598Jul 12 2006 — edited Jul 14 2006
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 + "?");
		}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 11 2006
Added on Jul 12 2006
4 comments
36 views