Skip to main content
GameDev.net gamedev.net
🔒 Locked

Java problem

Started by Yamulley Oct 19, 2008 at 2:23 PM 8 replies 3k views
Original Post
Yamulley
Yamulley
Hello. I learn java game programming, and at the moment 3d game programming from here [gamsutra.com] For code writing i use NetBeans 6.1. And i have some problem with this line in code: myTransform3D.setTranslation(new Vector3f(-1.0f,0.0f,-4.0f)); NetBeans output error: Example01.java:137: cannot find symbol symbol : class Vector3f location: class javaapplication6.Example01 myTransform3D.setTranslation(new Vector3f(-1.0f,0.0f,-4.0f)); 1 error Please help me and tell, how can i resolve this problem?
Yamulley
Yamulley
thanks for helping, but now i got other problem. I want run this java class from html page, but when i open it, only action, what happen is that orange java loading thing apears, but nothing else. Here is code:
<HTML><HEAD><TITLE>Hello World Applet</TITLE></HEAD><BODY><CENTER><H1>Hello World Applet</H1><APPLET CODE="Example01.class" WIDTH=400 HEIGHT=300></APPLET></BODY></HTML>


import java.awt.*; import java.awt.event.*;  import javax.media.j3d.*; import javax.vecmath.*;     public class Example01 extends Frame {   public static void main(String args[]) {     new Example01();   }   public Example01() {          super("Java 3D Example01");     setSize(400,300);       Canvas3D myCanvas3D = new Canvas3D(null);     add("Center",myCanvas3D);     setVisible(true);      addWindowListener(new WindowAdapter()        {public void windowClosing(WindowEvent e)           {dispose(); System.exit(0);}         }     );         View myView = constructView(myCanvas3D);     Locale myLocale = constructViewBranch(myView);     constructContentBranch(myLocale);   }     private View constructView(Canvas3D myCanvas3D) {     View myView = new View();     myView.addCanvas3D(myCanvas3D);    myView.setPhysicalBody(new PhysicalBody());     myView.setPhysicalEnvironment(new PhysicalEnvironment());     return(myView);   }    private Locale constructViewBranch(View myView) {      VirtualUniverse myUniverse = new VirtualUniverse();     Locale myLocale = new Locale(myUniverse);     BranchGroup myBranchGroup = new BranchGroup();     TransformGroup myTransformGroup = new TransformGroup();     ViewPlatform myViewPlatform = new ViewPlatform();     myTransformGroup.addChild(myViewPlatform);     myBranchGroup.addChild(myTransformGroup);     myLocale.addBranchGraph(myBranchGroup);     myView.attachViewPlatform(myViewPlatform);     return(myLocale);   }    private void constructContentBranch(Locale myLocale) {     Font myFont = new Font("TimesRoman",Font.PLAIN,10);     Font3D myFont3D = new Font3D(myFont,new FontExtrusion());     Text3D myText3D = new Text3D(myFont3D, "Gamasutra");     Shape3D myShape3D = new Shape3D(myText3D, new Appearance());        BranchGroup contentBranchGroup = new BranchGroup();     Transform3D myTransform3D = new Transform3D();     myTransform3D.setTranslation(new Vector3f(-1.0f,0.0f,-4.0f));     myTransform3D.setScale(0.1);     Transform3D tempTransform3D = new Transform3D();     tempTransform3D.rotY(Math.PI/4.0d);     myTransform3D.mul(tempTransform3D);     TransformGroup contentTransformGroup = new TransformGroup(myTransform3D);     contentTransformGroup.addChild(myShape3D);     contentBranchGroup.addChild(contentTransformGroup);     myLocale.addBranchGraph(contentBranchGroup);   } }







SimonHx
SimonHx
Quote:
public class Example01 extends Frame
{
}

try;
public class Example01 extends Applet{}


Yamulley
Yamulley
Yes i try, but there is some new problems. Now there is errors on these lines:

super("Java 3D Example01");

and:

addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{dispose(); System.exit(0);}
}

error in all cases is:
Cannot find simbol

nathandelane
nathandelane
Quote:
Original post by Yamulley
Yes i try, but there is some new problems. Now there is errors on these lines:

super("Java 3D Example01");

and:

addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{dispose(); System.exit(0);}
}

error in all cases is:
Cannot find simbol


If you want to be able to view your application on a web page, then you must extend Applet or JApplet (in javax.swing.*) instead of Frame or JFrame. If you want windowClosing to exist then you must "implement[s] WindowListener", and WindowListener is in java.awt.events.*.

So basically your first lines of your class will be something like (Note, I used a WindowAdapter to implement just one of the WindowListener methods):

import java.applet.Applet;import java.awt.event.WindowListener;import java.awt.event.WindowEvent;public class MyClass extends Applet implements WindowListener {    public MyClass() {        super("My Applet");    }    this.addWindowListener(new WindowAdapter() {      public void windowClosing(WindowEvent w) {        System.exit(0);      }    });}


I hope that helps you. A good resource is the Java API, located here http://java.sun.com/javase/6/docs/api/
Yamulley
Yamulley
I get error in this line:

public class MyClass extends Applet implements WindowListener {

error: implement all abstract methods
Shabadoo
Shabadoo
Just a thought, but it might be better to learn Java programming first, then move on to Java game programming. Find a good book, or start with some of the tutorials on the Sun website.
SimonHx
SimonHx
Quote:
Original post by Yamulley
Yes i try, but there is some new problems. Now there is errors on these lines:

super("Java 3D Example01");

and:

addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{dispose(); System.exit(0);}
}

error in all cases is:
Cannot find simbol

You can just remove those lines as applets don't need them. You'd do well to look at a basic applet tutorial as they do differ from Frames in some ways.
Have a look at: http://www.dgp.toronto.edu/~mjmcguff/learn/java/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.