Jbutton Netbeans Java

Asked

Viewed 19 times

0

How to check if the mouse CONTINUES over a button in java? I created a timer that after 1.5Segs performs the task of showing a Popup saying what the button does, but it still runs when you take the mouse from above before completing the 1.5.. What causes me a problem if the user just click and exit quickly with the mouse... The popup overlaps a Jconfirmdialog :/

1 answer

0

You can know when the mouse is on the button or any other element with this code:

 button.addMouseListener (novo MouseAdapter () {
 public void mouseEntered (MouseEvent e) {
    // seu código aqui (verificou que está sobre o botão)
 }

});

And to know that the mouse left and run something when identifying this, you can use the event:

mouseExited() 
  • I couldn’t implement this code... Could you give me an example using btadd button name... If the mouse is on top (entered) run a system.out.print("success")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.