I guess the file didn't make it. Here is a cut n paste.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.behaviors.vp.*;
import com.sun.j3d.utils.picking.behaviors.*;
import java.util.Enumeration;
public class TestButtons extends JFrame
{
class PickPoints extends Behavior
{
public PickPoints( Canvas3D canvas, Bounds bounds )
{
m_canvas = canvas;
setSchedulingBounds( bounds );
}
public void initialize()
{
conditions = new WakeupCriterion[1];
conditions[0] = new WakeupOnAWTEvent(MouseEvent.MOUSE_RELEASED);
//conditions[1] = new WakeupOnAWTEvent(MouseEvent.MOUSE_DOWN);
wakeupCondition = new WakeupOr(conditions);
wakeupOn(wakeupCondition);
}
public void processStimulus( Enumeration criteria )
{
WakeupCriterion wakeup;
AWTEvent[] evt = null;
while(criteria.hasMoreElements())
{
wakeup = (WakeupCriterion)criteria.nextElement();
if (wakeup instanceof WakeupOnAWTEvent)
evt = ((WakeupOnAWTEvent)wakeup).getAWTEvent();
}
if (evt[0] instanceof MouseEvent)
{
mevent = (MouseEvent) evt[0];
processMouseEvent(mevent);
}
wakeupOn( wakeupCondition );
}
public void processMouseEvent( MouseEvent e )
{
int xpos = 0, ypos = 0;
xpos = e.getPoint().x;
ypos = e.getPoint().y;
m_canvas.getImagePlateToVworld( m_eyeToVpc );
m_canvas.getPixelLocationInImagePlate( xpos, ypos, m_Point );
m_eyeToVpc.transform( m_Point );
updateScene( m_Point.x, m_Point.y, m_Point.z );
}
public void updateScene( double x, double y, double z )
{
m_Data[m_Cnt*3] = x;
m_Data[m_Cnt*3+1] = y;
m_Data[m_Cnt*3+2] = z;
m_Cnt += 1;
PointArray points = null;
points = new PointArray( m_Cnt,
GeometryArray.COORDINATES | GeometryArray.BY_REFERENCE );
points.setCoordRefDouble( m_Data );
m_PointShape.setGeometry( points );
}
protected WakeupCriterion[] conditions;
protected WakeupOr wakeupCondition;
protected MouseEvent mevent;
protected Canvas3D m_canvas;
protected Transform3D m_eyeToVpc = new Transform3D();
protected Point3d m_Point = new Point3d();
}
public TestButtons()
{
String plaf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
try {
UIManager.setLookAndFeel( plaf );
//SwingUtilities.updateComponentTreeUI( getContentPane() );
} catch( Exception e ) { }
setTitle("Test Buttons");
setSize( 300, 300 );
Container c = getContentPane();
c.setLayout( new BorderLayout() );
JPanel panel = new JPanel();
Box b = Box.createVerticalBox();
JButton button1 = new JButton( "Hello" );
b.add( button1 );
JToggleButton button2 = new JToggleButton( "Bubba" );
b.add( button2 );
panel.add( b );
c.add( "West", panel );
Canvas3D canvas = createCanvas();
SimpleUniverse univ = new SimpleUniverse( canvas );
// Create the viewing model
BoundingSphere bounds =
new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
PickPoints creator = new PickPoints( canvas, bounds );
BranchGroup scene = new BranchGroup();
m_PointShape = new Shape3D();
Appearance appear = new Appearance();
appear.setPointAttributes( new PointAttributes( 5.0f, true ) );
m_PointShape.setAppearance( appear );
m_PointShape.setCapability( Shape3D.ALLOW_GEOMETRY_READ );
m_PointShape.setCapability( Shape3D.ALLOW_GEOMETRY_WRITE );
scene.addChild( m_PointShape );
scene.addChild( creator );
univ.addBranchGraph( scene );
ViewingPlatform viewingPlatform = univ.getViewingPlatform();
viewingPlatform.setNominalViewingTransform();
c.add( "Center", canvas );
addWindowListener( new WindowAdapter()
{
public void windowClosing( WindowEvent evt )
{
System.exit(0);
}
} );
}
public Canvas3D createCanvas()
{
GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
GraphicsConfiguration gc1 =
GraphicsEnvironment.
getLocalGraphicsEnvironment().
getDefaultScreenDevice().
getBestConfiguration(template);
Canvas3D canvas = new Canvas3D( gc1 );
canvas.setDoubleBufferEnable(true);
return canvas;
}
public static void main( String[] args )
{
JFrame f = new TestButtons();
f.show();
}
protected double[] m_Data = new double[3 * 1000];
protected int m_Cnt = 0;
protected Shape3D m_PointShape;
}
===========================================================================
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".