Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » addActionListeners method undefined que from a newb
addActionListeners method undefined que from a newb [message #695060] Sun, 10 July 2011 22:36 Go to next message
mark jones is currently offline mark jonesFriend
Messages: 1
Registered: July 2011
Junior Member
Hi Guys, I'm learning Java going through CS106a online along with the recommended book and picking things up...have a newb que if anyone can point me in the right direction it would be appreciated....Here's the program taken from the book and i've highlighted the two probs in red.

the first says WEST cannot be resolved to a variable
the second says the method addActionListeners is undefined

Cheers, Mark

import acm.program.*;
import java.awt.event.*;
import javax.swing.*;

/*
* This program puts up a button on the screen, which triggers a
* message inspired by douglas Adam's Novel.
*/

public class HitcherhikerButton extends ConsoleProgram {

/* Initializes the user-interface buttons */
public void init() {
add(new JButton("RED"), WEST);
addActionListeners();
}

/* Responds to a button action */
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("RED")) {
println("Please do not press this button again.");
}
}
}


Re: addActionListeners method undefined que from a newb [message #696349 is a reply to message #695060] Wed, 13 July 2011 17:34 Go to previous message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
This forum is for discussions related specifically to Eclipse, not
general Java programming questions. Try www.stackoverflow.com for
general programming help.

Having said that... it's impossible to know what's going on without
seeing the ConsoleProgram class that you're extending.

Eric


On 7/10/11 6:36 PM, mark jones wrote:
> Hi Guys, I'm learning Java going through CS106a online along with the
> recommended book and picking things up...have a newb que if anyone can
> point me in the right direction it would be appreciated....Here's the
> program taken from the book and i've highlighted the two probs in red.
> the first says WEST cannot be resolved to a variable the second says the
> method addActionListeners is undefined
>
> Cheers, Mark
>
> import acm.program.*;
> import java.awt.event.*;
> import javax.swing.*;
>
> /*
> * This program puts up a button on the screen, which triggers a *
> message inspired by douglas Adam's Novel.
> */
>
> public class HitcherhikerButton extends ConsoleProgram {
>
> /* Initializes the user-interface buttons */
> public void init() {
> add(new JButton("RED"), WEST);
> addActionListeners();
> }
>
> /* Responds to a button action */
> public void actionPerformed(ActionEvent e) {
> if (e.getActionCommand().equals("RED")) {
> println("Please do not press this button again.");
> }
> }
> }
>
>
>
Previous Topic:Eclipse Plug-in Development - T-SQL Editor
Next Topic:GridLayout - GridData.exclude problem
Goto Forum:
  


Current Time: Fri Apr 19 22:21:26 GMT 2024

Powered by FUDForum. Page generated in 0.08794 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top