View Single Post
  #2 (permalink)  
Old 08-06-2007, 10:33 PM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Code:
C:\jexp>javac compiletest.java compiletest.java:7: CompileTest is not abstract and does not override abstract m ethod actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListen er public class CompileTest extends JApplet implements ActionListener ^ compiletest.java:36: cannot find symbol symbol : method getState() location: class javax.swing.JCheckBox if(cocktailBox.getState()) ^ compiletest.java:40: cannot find symbol symbol : method getState() location: class javax.swing.JCheckBox if(dinnerBox.getState()) ^ 3 errors
1 — The class signature implements ActionListener. The rule/contract with interfaces is this: if you implement an interface you promise to provide an implementation for each method it defines. Look up the ActionListener interface in the javadocs and find its only method is
Code:
public void actionPerformed(ActionEvent e) { }
This exact method signature must appear in the class that implements the ActionListener interface.
2 — getState is in the java.awt.Checkbox class api.
You are using a javax.swing.JCheckBox, a very different component. For this class you would use the isSelected method which JCheckBox inherits from its superclass AbstractButton - see JCheckBox api.

This method signature is incorrect.
Code:
public void itemStateChanged(ActionEvent check)
The itemStateChanged method is defined by the ItemListener interface and its argument is an ItemEvent.
Reply With Quote