Skip to Main Content

Java Programming

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!

AWT/AWT.EVENT Problem, I'm stumped, help please!

807591Mar 24 2008 — edited Mar 24 2008
There are 3 errors:
import java.awt.*;
import javax.swing.*;

public class ChatClient implements ActionListener <--- Error "ActionListener cannot be resolved to type"
{
	private TextArea output;
	private TextField input;
	private Button sendButton;
	private Button quitButton;
	
	public ChatClient()
	{
		output = new TextArea(10,50);
		input = new TextField(50);
		sendButton = new Button("Send");
		quitButton = new Button("Quit");
	}
	
	public void launchFrame()
	{
		Frame f = new Frame("Chat Room");
		
		f.setLayout(new BorderLayout());
		f.add(output, BorderLayout.WEST);
		f.add(input, BorderLayout.SOUTH);
		
		Panel p = new Panel();
		p.setLayout(new GridLayout(2,1));
		p.add(sendButton);
		p.add(quitButton);
		
		f.add(p, BorderLayout.CENTER);
		
		f.pack();
		f.setVisible(true);
		
		f.addWindowListener(new WindowAdapter()	
		{
			public void windowClosing(WindowEvent we)
			{
				System.exit(0);
			}
		} );
		
		public void actionPerformed(ActionEvent ae) <--- error here
		{
			if (ae.getSource() == sendButton)
			{
				sendButton.setText("You Clicked me!"); <--- error here "The method setText(String) is undefined for type button
			}
		}
	}
	
	public static void main(String args[])
	{
		ChatClient cc = new ChatClient();
		cc.launchFrame();
	}
}{code}

I'm stumped and these books I have are apparently crap if they cannot teach me how to do events correctly. Anyways...

Help please!

Thanks!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 21 2008
Added on Mar 24 2008
24 comments
1,203 views