JButton auto click

Discussion in 'Java' started by patrick, Apr 2, 2004.

  1. patrick

    patrick Guest

    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
     
    patrick, Apr 2, 2004
    #1
    1. Advertising

  2. In article <8%ebc.3043$>,
    "patrick" <> wrote:

    >: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 =
    --
    Steve W. Jackson
    Montgomery, Alabama
     
    Steve W. Jackson, Apr 2, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bao

    Help JButton

    Bao, Jul 18, 2003, in forum: Java
    Replies:
    2
    Views:
    442
    Kevin Pors
    Jul 19, 2003
  2. Allan Bruce
    Replies:
    3
    Views:
    1,740
    Phillip Mills
    Jun 15, 2004
  3. Replies:
    1
    Views:
    1,306
  4. Todd
    Replies:
    5
    Views:
    1,029
    Roedy Green
    Aug 23, 2007
  5. linkswanted
    Replies:
    1
    Views:
    927
Loading...

Share This Page