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!

About doClick() and JButton

843806May 7 2009 — edited May 7 2009
Dear,

I simulate a click on a JButton like this :
        if (e.getKeyCode() == 38) {
            this.panelControl.getJButtonUp().doClick(1000);
        }
I can see the JButton pressed ( thanks to setPressedIcon). But MousePressed see nothing :
   public void mousePressed(final MouseEvent e) {
        if (e.getComponent().getName().equals("up")) {
            buttonPressed = true;
            Thread t = new Thread(new Runnable() {
 
                public void run() {
                    while (buttonPressed) {
                        JButtonPan tmp = (JButtonPan) e.getSource();
                        Vector3f v = new Vector3f(0, trans, 0);
                        tmp.getObj().getTmpTrans().setTransform(move(e, v));
                        try {
                            Thread.currentThread().sleep((long) (10 + 100 / lin));
                            lin++;
                        } catch (InterruptedException e) {
                            return;
                        }
                    }
                }
            });
            t.start();
        }
When i use my mouse, it works, but it doesn't works with doCick(1000). Any idea please ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 4 2009
Added on May 7 2009
6 comments
433 views