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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

how to add to viewPlatformBehavior an Action Event - a button press

843799May 22 2010
And the main problem I have is to by pressing buttons to change the Viewing Platform?
I made same transformation to object, which reacts to key pressin:
 public class LewoPrawo extends Behavior{
    private TransformGroup targetLP;
    private Transform3D wysuwanie = new Transform3D();
    private float krok2 = (float) 0.0;
     // create LewoPrawo
    LewoPrawo(TransformGroup targetLP){
    this.targetLP = targetLP;
    }

     public void initialize(){            
            this. wakeupOn(new WakeupOnAWTEvent(AWTEvent.KEY_EVENT_MASK));
    }

    public void processStimulus(Enumeration enumeration){
        this.wakeupOn(new WakeupOnAWTEvent(AWTEvent.KEY_EVENT_MASK));

            KeyEvent event = (KeyEvent) ((WakeupOnAWTEvent) enumeration.nextElement()).getAWTEvent()[0];

           if (event.getKeyCode() == KeyEvent.VK_Q) {
               krok2 += 0.01;
           }
           if (event.getKeyCode() == KeyEvent.VK_W) {
               krok2 -= 0.01;
           }
           wysuwanie.set(new Vector3f(krok2, 0.0f, 0.0f));
           wysuwanie.mul(przewrocenie);
           targetLP.setTransform(wysuwanie);
    }
And this is the one that I made up to move the viewing platform, but it doesn't work!!!
public class Perspektywa extends ViewPlatformBehavior{

private TransformGroup targetVP;
private Transform3D obrot_obserwatora = new Transform3D();
private double kat=0.0;

//create Perspektywa

	Perspektywa(){
// ???	
	}

	public void initialize(){
	this.wakeupOn(new WakeupOnAWTEvent(AWTEvent.ACTION_EVENT_MASK));
	}

	
	public void processStimulus(Enumeration enumeration){
	this.wakeupOn(new WakeupOnAWTEvent(AWTEvent.ACTION_EVENT_MASK));
 	
ActionEvent event = (ActionEvent) ((WakeupOnAWTEvent) enumeration.nextElement()).getAWTEvent()[0];


	if (event.getSource()== przyciski[0])  {
           kat += 0.1;
       }
       if (event.getSource() == przyciski[3]) {
           kat -= 0.1;
       }

        obrot_obserwatora.rotY(kat);

        TransformGroup targetVP =
            simpleU.getViewingPlatform().getViewPlatformTransform();
        targetVP.getTransform( obrot_obserwatora);
        
        }
}
And what's worse, action events doesnt even work when i replace key events with them, but i don;t know why ;(

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 19 2010
Added on May 22 2010
0 comments
146 views