![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | AddRemove.class | 1998-02-05 17:06 | 1.8K | |
![]() | AddRemove.java | 1998-02-05 17:10 | 2.1K | |
![]() | README.html | 1998-01-26 17:26 | 2.1K | |
![]() | add-remove1.html | 1998-02-05 22:21 | 822 | |
![]() | root.wrl | 1998-01-22 09:28 | 79 | |
This README file is NOT a tutorial, we just outline a few interesting bits of code: Getting a handle on a DEFed object in the scene. In this cas a Group (could be Transform) Node called ROOT (see the file root.wrl)
// Get root node of the scene, and its EventIns root = browser.getNode("ROOT");Once we got the handle we can get a handle to the field EventIn "addchildren" and to the field EventOut "removechildren"
addChildren = (EventInMFNode) root.getEventIn("addChildren"); removeChildren = (EventInMFNode) root.getEventIn("removeChildren");This inserts 2 Java buttons into the applet:
add(addButton = new Button("Add Sphere")); add(removeButton = new Button("Remove Sphere"));The Java method below will catch user events (e.g. user clickin on the Add Sphere Button) and then call the xxx.setValue methods. xxx is a handle for the Event fields (see above) and .setValue will set a value (in this case pass a node reference to be added or removed).
public boolean action(Event event, Object what) { // Catch all Events from type Button if (event.target instanceof Button) { Button b = (Button) event.target; // either addButton or removeButton has been clicked on if (b == addButton) { addChildren.setValue(shape); } else if (b == removeButton) { removeChildren.setValue(shape); } } return true; }