Results 1 to 2 of 2
  1. #1
    sandor is offline Member
    Join Date
    Apr 2007
    Location
    Pennsylvania,USA
    Posts
    45
    Rep Power
    0

    Default Mouse over JButton

    I have an 10 x 10 array of JButtons in my project. I was just wondering how do i find out which button the mouse cursor is over at any given time?
    I have tried adding the following to the buttons:
    Java Code:
    b.addMouseMotionListener(new MouseMovingHandler());
    b.addMouseListener(new MouseHandler());

  2. #2
    derrickD is offline Member
    Join Date
    Apr 2007
    Location
    USA
    Posts
    50
    Rep Power
    0

    Default

    You can try to use the mouseEntered method in MouseListener and you can try to get the X and Y coordinates from the mouse and check which button it is on. Which would be getX and getY from the MouseEvent.

Similar Threads

  1. Mouse dragg not working
    By Preethi in forum AWT / Swing
    Replies: 1
    Last Post: 02-08-2008, 04:51 AM
  2. The mouse and the cheese
    By Don Quixote in forum Java 2D
    Replies: 4
    Last Post: 08-15-2007, 10:55 PM
  3. How to mouse-drag a JWindow?
    By cruxblack in forum New To Java
    Replies: 3
    Last Post: 08-06-2007, 09:52 AM
  4. mouse over on JButton
    By gradon in forum Java Applets
    Replies: 1
    Last Post: 08-04-2007, 05:50 AM
  5. Use the mouse position
    By susan in forum Java Applets
    Replies: 1
    Last Post: 07-28-2007, 11:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •