JButton auto click

P

patrick

I want to use a JButton like this: when a user leaves the mouse pointer in a
fixed position over the button a click is generated without the user having
to do the mousepress.

Ive got an array of JButtons on a JPanel that i would like to have this
property.

Anybody know of a java code snippet that would help in doing this.

Or is there an easy way of doing this?

TIA
patrick

Wonder if this
 
S

Steve W. Jackson

patrick said:
:I want to use a JButton like this: when a user leaves the mouse pointer in a
:fixed position over the button a click is generated without the user having
:to do the mousepress.
:
:Ive got an array of JButtons on a JPanel that i would like to have this
:property.
:
:Anybody know of a java code snippet that would help in doing this.
:
:Or is there an easy way of doing this?
:
:TIA
:patrick
:
:Wonder if this

If I were to see an app/applet with this behavior, I'd probably refuse
to use it. But you should be able to do it if you're really insistent.

One way might be this. Since JButton inherits from Component, you can
add a MouseListener to it. When you get a mouseEntered event, you could
set up a timer (if you want a delay) and start it, and then stop the
timer on mouseExit. And the timer's job would essentially be to call
doClick() on the button.

= Steve =
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top