Your behavior should *not* set the wakeup criteria at construction time. Instead, set it when you press the button. In order to do that, don't invoke resetEvents() in the initialize method, but invoke it when you press the button.
Cheers, Florin -----Urspr�ngliche Nachricht----- Von: A. Murat Tanyer [mailto:[EMAIL PROTECTED] Gesendet: Montag, 17. M�rz 2003 16:24 An: [EMAIL PROTECTED] Betreff: Re: [JAVA3D] help Hi Alessandro, 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 using > > setChildMask(java.util.BitSet childMask) > were childMask is a java.util.BitSet object (see javadocs). > > By using it you can select correctly what will appear or not. > Use constans to label your TGs > > > BG > | > SW > / | \ > TG1 TG2 TG3 > > > // use same sequence you add to switch > int 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 TG1 > mask = switch.getChildMask(); > mask.set(TG1_BIT); > switch.setChildMask(mask); > > // to show TG2, no show Tg3, show TG1 > mask = 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 Tanyer <mailto:[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> > Sent: Monday, March 17, 2003 9:12 AM > Subject: [JAVA3D] help > > Dear 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); > } > } > } > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------ > ==========================================================================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".
