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
精彩评论