Tony Docherty wrote:And, whilst this doesn't affect the operation of your code, you've called your variable 'C'. Two things: variables in Java, by convention, start with a lower case letter and you should always use meaningful names for variables. You may know what 'C' is as you've just written the code but in 6 months time you probably won't and more importantly it makes it hard for other people to read and understand your code.
Matthew Brown wrote:You've declared your C variable as a local variable within the constructor. You need to declare it as an instance variable if you want to be able to access it in other methods.
Paul Clapham wrote:You want less cryptic? Check your spelling.
Paul Clapham wrote:
Kevin Corina wrote:I think its bugging out over the fact I overridden the actionPreformed method from GraphicsBox.
What method was that again? No, you didn't override the method you mentioned there. That's because there is no such method to override. There is however another method with a very similar name which you should have overridden, but didn't. Look more carefully at the error message and the line of code you think is right but you know is wrong.
Steve Luke wrote:Also: regarding this: Up.CreateActionListener(new UpListener()); in the Firestarter code. A JButton does not have a method named CreateActionListener(). It has a method named createActionListener() (difference is the captial C versus lower case c, Java is case-sensitive). But that method doesn't take an ActionListener as a parameter (is has an empty parameter list) and is probably not accessible by your code. So, not sure what you are trying to do there but whatever it is, it won't work.
Steve Luke wrote:
Kevin Corina wrote:What I need to understand is how I can have a non-static counter of interact with static methods inside of inner classes "UpListener" and "DownListener" Is there a method similar to "AddActionListener", but non-static? That way I could make two new actionListeners and THEN apply them to a JButton?
I am not sure what your question is, but JButton#addActionListener() is not static. From what I can see, the one method inside UpListener and DownListener is the non-static method actionPerformed(). I think that SSCCE is needed, and you need to explain in more detail the issue you are having, because what you said doesn't match the code or how JButton or ActionListener (or an interface for that matter) works.
Campbell Ritchie wrote:Welcome again.
You have to imagine that the loop creates a temporary variable which is a copy of the next element in the List. You can use that temporary varaible, and change it, but that does not affect the original List/array/whatever. The Oracle link which Jesper quoted does say it doesn’t cover all possibilities, but they preferred to go for simple syntax.