So I’m getting experience on this stuff little by little, but this problem seems so… weird, and almost unfair, that I don’t know what to do. To explain, here is my code:
import java.awt.*;
import java.util.*;
import javax.media.j3d.*;
import javax.swing.Timer; //I import the Timer class here, it is accepted
import javax.vecmath.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.behaviors.keyboard.*;
import com.sun.j3d.utils.behaviors.vp.*;
import com.sun.j3d.utils.geometry.*;
public class Scene extends BranchGroup {
public Scene () {
Transform3D translate = new Transform3D ();
translate.setTranslation (new Vector3d (0f, 0f, -10.f));
TransformGroup objTranslate = new TransformGroup (translate);
this.addChild (objTranslate);
Box box = new Box (0.7f, 0.7f, 0.7f, new Appearance());
objTranslate.addChild (box);
javax.swing.Timer timer = new javax.swing.Timer(5, this); //error message "The constructor Timer(int, Scene) is undefined"
timer.start();
}
}
Don’t pay too much attention to the biggest part of the code, it is still a draft, will be refined later. The problem is with the timer, which always returns The constructor Timer(int, Scene) is undefined. I’ve added as much imports as I could, defined as clearly as possible in which import the Timer class was, etc. timer.start() works fine, so I suppose the class is recognised anyway. But the program won’t run, because it’s undefined. Even though imported. And I have no idea why.
Would one of you have an idea, or would be able to explain what is going on?
Thanks!
Your
Sceneclass is not implementingActionListener. Seeherehere.In other words, the
Timerclass does not have a constructor that takes anintand aSceneorBranchGroup. It only has a constructor that takes anintand anActionListener.