File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes 'Shuffling' GUI fx using Mouse Motion Event listener code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

'Shuffling' GUI fx using Mouse Motion Event listener code

Simon Evans
Ranch Hand

Joined: Mar 27, 2008
Posts: 93
Dear Programmers,
I wanted to code a program that would use a mouse motion cursor activated listener so that images on a GUI wouldn't just change once, but go through a sequence of changes for as long as the mouse is left upon a particular square or area of the GUI.

I wanted to create a 'shuffling' of cards effect - so that if the cursor were moved one square - it'd go through the entire suite from say 2 of Diamonds, through 3,4,5,6,7,8,9,10,Jack, Queen, King, Ace, then proceed to 2 of say Hearts, and so on.

If the cursor were moved to another square in the GUI - the same sequence would be gone through, until the cursor were moved, in that way each time the cursor is shifted around the GUI, the GUI would display a different set of cards - as each square therin would stop its 'shuffling' sequence at a particular card, once the cursor had left it.

Anyhow, that is my concept. I would like to know if any of you could suggest some useable code out there, for instance in a tutorial on the net, that does something like this - ie display an image sequence (than just one color change) in response to a mouse motion event.

Obviously it would use Action Performed/ Listener Event code, but my present knowledge can only accomplish the aforementioned one color change as an event response.

If you could give me some leads I would be very pleased.

Thank you for your attention


Larry Frissell
Ranch Hand

Joined: May 16, 2008
Posts: 82
It sounds to me like game programming, this is just one site of many that talk about using mouse events in a game. It's a start. Good Luck!
Simon Evans
Ranch Hand

Joined: Mar 27, 2008
Posts: 93
Dear Larry Frissell,

Thank you for your response.

I don't think I have explained what I had in mind as clearly as I might have, in restrospect.

The changing sequence of images I had in mind, don't have to be the sequence of a pack of cards, it could be any sequence of images - road signs, the alphabet, sephamore, or heiroglyphs even.

All I want is for the mouse motion event to do is to go through a sequence (be they predetermined or random) of stored images, rather than making just one image - or colour appear upon shifting the mouse cursor over that listener enabled area of the GUI.

At present I know how to make a colour appear upon shifting the mouse over it - but I want something a bit more spectacular ie: the presentation of an image, and preferably a sequence of images, until the mouse is moved off that listener enabled area of the GUI.

I've looked at the site you recommended, but that, as you suggested is about making a game (a ping pong game) which isn't really what I had in mind. I think what I have in mind is much simpler than Game design (ie game design is far too advanced for me or what I have in mind at present).

If you, or anyone can give me advice, again I would be grateful.

Thanks for your assistance.


Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46412
There appear to be answers on another thread; in view of the similarity of the questions, I am closing this thread; please continue discussions on the other thread.
I agree. Here's the link:
subject: 'Shuffling' GUI fx using Mouse Motion Event listener code
It's not a secret anymore!