开发者

How to change which Component is listening for events

开发者 https://www.devze.com 2023-04-04 10:45 出处:网络
I\'m trying to cycle between buttons programmatically, so I need to be able to change which button is listening for events when I move right/left or up/down.

I'm trying to cycle between buttons programmatically, so I need to be able to change which button is listening for events when I move right/left or up/down.

I have tried button.setSelection(true); inherited from AbstractButton but this is clearly not the sam开发者_StackOverflowe thing.

I have looked around and not found much for this dilemma so far, point the way if you could please.

Update: All I really want to do is give a button focus programmatically. All I see are "setFocusable" etc. in the methods; how would I do something like:

Button1.giveFocus();??


As a rule, you have always add event listener to component and only then get listen to the event :)

If you look at the mouse listener and its methods as the

public void mouseEntered(MouseEvent e) {
       saySomething("Mouse entered", e);
    }

    public void mouseExited(MouseEvent e) {
       saySomething("Mouse exited", e);
    }

Good luck

0

精彩评论

暂无评论...
验证码 换一张
取 消