Has anyone worked with custom cursors in a Java3D app?  I'm having some
problems
getting it to work.  My goal is to make the mouse cursor disappear.  I have an
example shown in the first fragment below that works fine
(cursortest.java).  In
my Java3D app though I get

java.lang.NullPointerException
        at sun.awt.CustomCursor.<init>(CustomCursor.java:40)
        at sun.awt.windows.WCustomCursor.<init>(WCustomCursor.java:30)
        at sun.awt.windows.WToolkit.createCustomCursor(WToolkit.java:618)
        at PlatNavigatorBehavior.<init>(PlatNavigatorBehavior.java:86)
        at LandGen.createSceneGraph(LandGen.java:77)
        at LandGen.<init>(LandGen.java:39)
        at LandGen.main(LandGen.java:23)

The line PlatNavigatorBehavior.java:86 is marked with >>>> below.  I would
appreciate any help that I can get.

Ken Causey
ineffable

--------------------------------------
This works:
--------------------------------------

// Fragments for cursortest.java

public class cursortest extends Frame {

   public cursortest(){
      super("Cursor Test");
      this.setSize(200,200);
      show();
      Toolkit t = this.getToolkit();
      Image temp = this.createImage(32,32);
      blankCursor = t.createCustomCursor(temp,new Point(0,0),new
String("Blank"));
   }
--------------------------------------


--------------------------------------
This doesn't:
--------------------------------------

// Fragments from LandGen.java

public class LandGen extends Frame {

   public LandGen() {
      setLayout(new BorderLayout());

      graphicsConfig = SimpleUniverse.getPreferredConfiguration();
      Canvas3D canvas3d = new Canvas3D(graphicsConfig);
      add("Center", canvas3d);

      SimpleUniverse su = new SimpleUniverse(canvas3d);

      // This will move the ViewPlatform back a bit so the
      // objects in the scene can be viewed.
      su.getViewingPlatform().setNominalViewingTransform();

      BranchGroup scene = createSceneGraph(su);

      su.addBranchGraph(scene);
   }

   public BranchGroup createSceneGraph(SimpleUniverse su){
      TransformGroup vpTrans = null;
      BoundingSphere navBounds = null;

      vpTrans = su.getViewingPlatform().getViewPlatformTransform();

      BranchGroup objRoot = new BranchGroup();

      objRoot.addChild(new ColorCube(0.4));

      navBounds = new BoundingSphere(new Point3d(), 1000.0);

      PlatNavigatorBehavior navBehavior = new
PlatNavigatorBehavior(vpTrans,graphicsConfig,this);
      navBehavior.setSchedulingBounds(navBounds);
      objRoot.addChild(navBehavior);

   // Let Java 3D perform optimizations on this scene graph.
      objRoot.compile();

      return objRoot;
   }

// Fragments from PlatNavigatorBehavior.java

public class PlatNavigatorBehavior extends Behavior {

   public PlatNavigatorBehavior(TransformGroup platform,
GraphicsConfiguration gc, Frame frame) throws NoRobotCreatedException {
      mainFrame = frame;
      Toolkit t = mainFrame.getToolkit();
      Dimension dim = new Dimension();
      dim = t.getBestCursorSize(0,0);
      System.out.println("getBestCursorSize returned ("+dim.width+",
"+dim.height+")");
      Image temp = mainFrame.createImage(dim.width,dim.height);
>>>>  blankCursor = t.createCustomCursor(temp,new Point(0,0),new
String("Blank"));
      pnav = new PlatNavigator(platform);
   }
------------------------------

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to