> Desiree,
>
> Is your canvas3D "live" at the time you check focus?
What exactly, do you mean with live?
I can see it, and it has some 3D content in it, which I can see as well.
Perhaps put in a
> setVisible(true) on whatever contains your canvas3D and THEN check
> status of focus.
I have a GIS3DView which is extended from JPanel.
In this GIS3DView I am adding the Canvas3D.
Calling a MenuItem now leads me to my current
actionPerformed method:
// set place of clipping plane
if (e.getActionCommand().equals("twodims")) {
Component comp = tab.getSelectedComponent();
if (comp instanceof GIS3DView) {
GIS3DView gis3dViewTwoDim = (GIS3DView) comp;
Canvas3D canvas3D = gis3dViewTwoDim.getCanvas3D();
//gis3dViewTwoDim.addGIS3DViewChangeListener(this);
if (checkitem2DClip.isSelected()) {
// Make clipping planes
VerticalClippingPlane plane1 = new
VerticalClippingPlane(new
Vector3d(1.0,0.0,0.0),0,VerticalClippingPlane.Java3D);
VerticalClippingPlane plane2 = new
VerticalClippingPlane(new
Vector3d(-1.0,0.0,0.0),-10,VerticalClippingPlane.Java3D);
originClipNode = new
OriginClipping(gis3dViewTwoDim,plane1,plane2);
originClipNode.enablePlane(1,true);
originClipNode.enablePlane(2,false);
originClipNode.addClippingNode();
TransformGroup rotateClipTg =
originClipNode.getMoveClipNode();
BoundingSphere mouseBounds =
gis3dViewTwoDim.getMouseBounds();
// Add rotate behavior of clipping plane
RotateClipBehavior rotateClipBehave = new
RotateClipBehavior(rotateClipTg,gis3dViewTwoDim);
rotateClipBehave.setSchedulingBounds(mouseBounds);
rotateClipBg = new BranchGroup();
rotateClipBg.setCapability(Group.ALLOW_CHILDREN_READ);
rotateClipBg.setCapability(Group.ALLOW_CHILDREN_WRITE);
rotateClipBg.setCapability(BranchGroup.ALLOW_DETACH);
rotateClipBg.addChild(rotateClipBehave);
gis3dViewTwoDim.getSceneTg().addChild(rotateClipBg);
// Add zoom behavior of clipping plane
ZoomClipBehavior zoomClipBehave = new
ZoomClipBehavior(rotateClipTg,gis3dViewTwoDim);
zoomClipBehave.setSchedulingBounds(mouseBounds);
zoomClipBg = new BranchGroup();
zoomClipBg.setCapability(Group.ALLOW_CHILDREN_READ);
zoomClipBg.setCapability(Group.ALLOW_CHILDREN_WRITE);
zoomClipBg.setCapability(BranchGroup.ALLOW_DETACH);
zoomClipBg.addChild(zoomClipBehave);
gis3dViewTwoDim.getSceneTg().addChild(zoomClipBg);
/////////////// Attention, here I am trying to request the focus!
/////////////// I added the setVisible, but nothing changes.
gis3dViewTwoDim.setVisible(true);
canvas3D.addKeyListener(this);
canvas3D.requestFocus();
System.out.println("hallo"+canvas3D.hasFocus());
///////////// Output: hallofalse
}
else {
originClipNode.enablePlane(1,false);
originClipNode.enablePlane(2,false);
originClipNode.removeClippingNode();
if (rotateClipBg!=null)
rotateClipBg.detach();
if (zoomClipBg!=null)
zoomClipBg.detach();
canvas3D.removeKeyListener(this);
}
}
}
Sorry I do not understand this.
Thanks for your help Desiree
I'm fairly sure our code sets focus like you are doing
> and has been working correctly for over a year. (I think Sun does some
> weird stuff with focus though as I've had some really bad nightmares in
> the past when I tried to control focus).
>
> - John Wright
> Starfire Research
>
> Desiree Hilbring wrote:
> >
> > Hi,
> >
> > I am attaching a KeyListener to my Canvas3D. Then I try to request the
> > focus for the Canvas3D afterwards.
> >
> > This is the code:
> >
> > canvas3D.addKeyListener(this);
> > canvas3D.requestFocus();
> > System.out.println("hallo"+canvas3D.hasFocus());
> >
> > The System.out.println prints "false" for the focus of the Canvas3D, why?
> >
> > The KeyListener works fine from that moment, when I move my mouse over the
> > Canvas3D. Can I give the Canvas3D the focus without the mouse being over
> > it?
> >
> > Thanks for your help in advance
> >
> > Desiree
> >
> > oooooooooooooooooooooooooooooooooooooooooooooooo
> > Desiree Hilbring
> >
> > Institut fuer Photogrammetrie und Fernerkundung
> > Universitaet Karlsruhe, Germany
> > email: [EMAIL PROTECTED]
> > # 0721 6083676
> > oooooooooooooooooooooooooooooooooooooooooooooooo
> >
> > ===========================================================================
> > 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".
>
===========================================================================
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".