Hi,

We have discovered a flicker or flash bug when using a Swing Menubar that has 
pulldowns covering a Canvas3D.  We think the bug comes from swing because the Canvas3D 
handles double buffering without problems by itself.  Here is a demo program for you 
to compile and run.  To see the bug just traverse the JMenubar items and look for a 
flash on the canvas.  We have seen this bug on all our PC's and Sun workstations 
running jdk1.2.1 and newer with Java3D (1.1 and the 1.2alpha release).

This bug demo creates a simple JFrame with a JMenuBar and a Canvas3D.  The contents of 
the canvas scenegraph are taken directly from the SUN Java3D demo called 
HelloUniverse.java.

Thanks,
Gregg Hock
[EMAIL PROTECTED]



import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.vecmath.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;

public class FlashBugDemo
{

public static void main(String[] args)
{

  FlashBugDemo bd = new FlashBugDemo();
  bd.init();
}

public void init()
{

  //Create main container
  final JFrame f = new JFrame("FlashBugDemo JFrame Window");
  f.getContentPane().setLayout(new BorderLayout());


  //Create JMenuBar
  JPopupMenu.setDefaultLightWeightPopupEnabled(false);
  JMenuBar jmb = new JMenuBar();
  JMenu jm = new JMenu("File");
  jm.add("file menu item1");
  jm.add("file menu item2");
  jm.add("file menu item3");
  jmb.add(jm);
  JMenu jm2 = new JMenu("Edit");
  jm2.add("edit menu item1");
  jm2.add("edit menu item2");
  jm2.add("edit menu item3");
  jmb.add(jm2);
  JMenu jm3 = new JMenu("Tools");
  jm3.add("tools menu item1");
  jm3.add("tools menu item2");
  jm3.add("tools menu item3");
  jmb.add(jm3);


  //Add JMenuBar to the JFrame
  f.setJMenuBar(jmb);

  //Create JPanel for Canvas3D component
  JPanel jp = new JPanel();
  jp.setLayout(new BorderLayout());
  GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
  Canvas3D can = new Canvas3D(config);
  //can.setBackground(Color.black);
  //Create the scene for the canvas (typical java3D)
  BranchGroup scene = createSceneGraph();
  SimpleUniverse universe = new SimpleUniverse(can);
  //Set an initial eye point...(custom code)
  universe.getViewingPlatform().setNominalViewingTransform();
  //Attach the scene
  universe.addBranchGraph(scene);
  //Add Canvas3D to the JPanel
  jp.add(BorderLayout.CENTER, can);

  //Add JPanel to the JFrame
  f.getContentPane().add(BorderLayout.CENTER, jp);

  //Finish JFrame specifications
  f.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent event) {
      f.dispose();
      System.exit(0);
    }
  });

  //f.setBounds(0,0,1000,1000);
  f.setSize(1000,1000);
  //f.pack();
  f.setVisible(true);

}
    public BranchGroup createSceneGraph() {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();

    // Create the transform group node and initialize it to the
    // identity.  Enable the TRANSFORM_WRITE capability so that
    // our behavior code can modify it at runtime.  Add it to the
    // root of the subgraph.
    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objRoot.addChild(objTrans);

    // Create a simple shape leaf node, add it to the scene graph.
    objTrans.addChild(new ColorCube(0.4));

    // Create a new Behavior object that will perform the desired
    // operation on the specified transform object and add it into
    // the scene graph.
        AxisAngle4f axisAngle = new AxisAngle4f(0.0f, 0.0f, 1.0f,
                                                -(float)Math.PI / 2.0f);
    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
                    0, 0,
                    4000, 0, 0,
                    0, 0, 0);

    RotationInterpolator rotator =
        new RotationInterpolator(rotationAlpha, objTrans, yAxis,
                     0.0f, (float) Math.PI*2.0f);
    BoundingSphere bounds =
        new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
    rotator.setSchedulingBounds(bounds);
    objTrans.addChild(rotator);

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

    return objRoot;
    }


}

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

Reply via email to