English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I copied the syntax exactly from a working example but get the following error:

init:
deps-jar:
Compiling 1 source file
Test.java:29: cannot find symbol
symbol : constructor Frame(Test)
location: class java.awt.Frame
Frame frame = new Frame(new Test());

Here is all the code up to that point:

import java.awt.BorderLayout;
import java.awt.*;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class Test extends Frame
{
public VirtualUniverse myUniverse = new VirtualUniverse();
public Locale myLocale = new Locale(myUniverse);
public BranchGroup myBranchGroup = new BranchGroup();
public TransformGroup myTransformGroup = new TransformGroup();
public ViewPlatform myViewPlatform = new ViewPlatform();

public void main(String[] args)
{
Frame frame = new Frame(new Test());

2006-09-15 08:40:28 · 3 answers · asked by madmarkuk2003 2 in Computers & Internet Programming & Design

3 answers

Wow, there must be more code in your class somewhere? Anyway, I think what you MEANT to write on the last line shown is this:

Frame frame = new Test();

since your Test class is a subclass of Frame. You're getting the error because Frame does not have a constructor that takes a Test, Frame, or any other object in the Frame hierarchy. I also assume you create a canvas for displaying your universe and that it gets added to the Test object somewhere in your Test constructor, or else you won't see anything.

2006-09-15 12:58:42 · answer #1 · answered by vincentgl 5 · 0 0

You're getting an error because you're trying to create a new Frame with your Test class as input - but there's no constructor of Frame with Test or Frame as an argument.

Anyways... if you wanna get rid of this error, somewhere in your Test class create a method named toString() that returns a String, eg:

public String toString() {
String frameName = "My Test Frame";
return frameName;
}

public void main(Strings[] args) {
Frame frame = new Frame(new Test());
...
...
}

Hope this helps

2006-09-15 15:54:57 · answer #2 · answered by SmartSpider 4 · 0 0

As the error says you have no default constructor declared in the class Test... declare one, put a super() in it and everything should compile ok...
declare in the test class:

public Test()
{
super();
}

2006-09-15 15:49:50 · answer #3 · answered by None A 3 · 0 0

fedest.com, questions and answers