Thanks for your reply,
I understand that my use of switch is not the correct way. I will change it according to your advices. However, my question is how I can link my behaviour with the JButton event so that the cubes are woke up when I press the button? At the moment the cubes woke up 3 seconds after the scene construction.
I think I have to have two criteria for this; first is the elapsed time the other is the press event of the JButton. But how can I detect that the particular Button is pressed?
Regards,
Murat
Alessandro Borges wrote:
Murat,You can use only one Switch to show the cubes you want by usingsetChildMask(java.util.BitSet childMask)were childMask is ajava.util.BitSet
object (see javadocs).By using it you can select correctly what will appear or not.Use constans to label your TGsBG|SW/ | \TG1 TG2 TG3// use same sequence you add to switchint TG1_BIT = 01;int TG2_BIT = 02;int TG3_BIT = 03;BitSet mask = new BitSet();...Swich switch = new Switch();switch.setWhichChild(Switch.CHILD_MASK);...//to show TG1mask = switch.getChildMask();mask.set(TG1_BIT);switch.setChildMask(mask);// to show TG2, no show Tg3, show TG1mask = switch.getChildMask();mask.set(TG1_BIT);mask.set(TG2_BIT);mask.clear(TG3_BIT);I did not test above code, but I use a "look alike" one in a demo.Alessandro----- Original Message -----From: A. Murat TanyerSent: Monday, March 17, 2003 9:12 AMSubject: [JAVA3D] helpDear all,
I am working on a small test program. I have three ColorCubes in my scene, all attached to different switches (see attached for the scenegraph). I am rendering only the first of these cubes by the switch statements.
I want to wakeup the other two cubes three seconds after I press the button on the GUI. I created a time behaviour class which uses WakeupOnElapsedTime(3000). But the problem is that the cubes are woke up three seconds after the scene is constructed. How can I link my behaviour with the JButton event so that the cubes are woke up when I press the button?
Thanks
public void initialize()
{
System.out.println("INITIALIZED");
critter = new WakeupOnElapsedTime(3000);
resetEvents();
}
protected final void resetEvents()
{
wakeupOn(critter);
}
// protected abstract void processAWTEvent(AWTEvent evt);
public void processStimulus(Enumeration criteria)
{
System.out.println("RUNNING PROCESS STIMULUS");
WakeupCondition cond;
while(criteria.hasMoreElements())
{
cond = (WakeupCondition)criteria.nextElement();
if(cond instanceof WakeupOnElapsedTime)
{
System.out.println("WAKE UP");
Switch1.setWhichChild(Switch.CHILD_NONE);
Switch2.setWhichChild(Switch.CHILD_ALL);
Switch3.setWhichChild(Switch.CHILD_ALL);
}
}
}
![]()
![]()