Here is a demonstration of the Jmenubar ~ Canvas3D flashing bug. I have
created a simple Jframe with a JMenuBar and a Canvas3D. The canvas
scenegraph is from the HelloUniverse Java3D demo. The flashing bug is
present on a variety of SUN workstations (Ultra 1,2, 30,60) and any jdk
(1.2.1_02, 04, 1.2.2, and 1.3beta) and Java3D 1.1.2, 1.2alpha.
We think the popup event from the menu pulldowns is incorrectly telling the
Canvas to completely repaint itself. Either that or something is not
correct in the dubble buffering code.
Cheers,
Gregg
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 JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".