Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Changing appearance on live objects, can't figure out the proper capability

843799Oct 25 2006 — edited Oct 18 2010
I've been trying to change the appearance of given objects in my scene graph (Box objects) in response to being picked. However, I keep getting a:

Shape3D: no capability to set appearance

error, and can't seem to figure out what capability I must set the Box objects to allow. Here is the pertinent code so far,

(within the class that creates a Box)
box.setCapability(Box.ALLOW_PICKABLE_READ);
box.setCapability(Box.ALLOW_PICKABLE_WRITE);
box.setCapability(Box.ENABLE_APPEARANCE_MODIFY);
box.setCapability(Box.ENABLE_PICK_REPORTING);

(within the picking class)

public class PickingListener extends MouseAdapter {

private PickCanvas pickCanvas;
private Box p;

public PickingListener(PickCanvas pickCanvasArg) {
pickCanvas = pickCanvasArg;
}

public void mouseClicked(MouseEvent e) {
pickCanvas.setShapeLocation(e);
PickResult result = pickCanvas.pickClosest();
if (result == null) {
System.out.println("Nothing picked");
} else {
p = (Box)result.getNode(PickResult.PRIMITIVE);
if (p != null) {
setSelectedColor();
System.out.println(p.getClass().getName());
System.out.println((((BarInformation)p.getUserData()).toString()));
} else{
System.out.println("null");
}
}
}

private void setSelectedColor() {
Appearance barAppearance = new Appearance();
ColoringAttributes barCA = new ColoringAttributes();
barCA.setColor(ColorConstants.SELECTED);
barAppearance.setColoringAttributes(barCA);
p.setAppearance(barAppearance);
}

Being unable to set the objects color/appearance after going live has been very frustrating. Any help offered will be greatly appreciated!

-Adrian
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 15 2010
Added on Oct 25 2006
9 comments
5,089 views