473,320 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Mouse cursor over a JButton??

Hi there,

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

Cheers,

Ragaman
Apr 9 '07 #1
1 2722
Well 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.

BSCode266
Apr 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Robin Shuff | last post by:
Hi, I'm trying to limit the movement of the mouse cursor in using a VB app. The idea is to stop the cursor straying on to the second monitor of a dual screen set-up (i.e. a projector) while this...
1
by: Tee | last post by:
Hi, From my main form, I am executing another application using System.Diagnostics.Process.Start. The application has its own window displaying when the applicaiton is run. I want to change...
10
by: Danny | last post by:
How can I get the coordinates of the mouse cursor in Mozilla browsers as well as Opera and IE6? I'm struggling to understand how to capture mouse movement events with Mozilla/Netscape/Firefox and...
2
by: Gas | last post by:
Hi, I also want to know how to change the mouse cursor to normal, hourglass.....etc. in runtime thanks Gas
3
by: Tim | last post by:
Hi, How would I go about changing the windows mouse cursor ? (Not the mouse cursor on a form...but the actual mouse cursor in windows..) Any ideas would be greatly appreciated Thanks, Tim
1
by: Tim | last post by:
Hi, I would like to create a custom mouse cursor for my print preview page. I want to use a bitmap of a magnifiying glass with a plus in it. Pretty standard stuff. How do I change the cursor?...
0
by: ragaman123 | last post by:
Hello everyone, I have an 10 x 10 array of JButtons in my battleships project, which represent the sea. I was just wondering how do i find out which button the mouse is over at any given time? I...
3
by: =?Utf-8?B?Vk1BTQ==?= | last post by:
Hi, I have a windows form with a ownerdraw combobox. When I draw the combobox items I also change the mouse cursor to something different than Cursors.Default. When the DropDown opens and the...
0
by: Studlyami | last post by:
I am trying to find how windows translate the input from a HID device to an actual windows message; specifically, the mouse. I am trying to figure out how when the mouse moves the process windows...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.