Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Attaching items to a mouse pointer  (Read 2338 times)
0 Members and 1 Guest are viewing this topic.
Offline dayrinni

Junior Devvie





« Posted 2006-05-01 19:01:46 »

Hi,

I am working on a project where I can select items from the screen, say, an image of some sorts.

The idea is I will click on this image and a screen will pop up, I will then select from a list on this screen 1 other item or a group of items, and then click OK. When I click OK another image will be created and attached to my mouse pointer. I can then move my mouse around with the image and click at a certain point on the screen to deposit my image there.

I have looked at the java API and under the mouse section (ie: mouse listener, etc), but there doesn't  appear to be anything like this. Is it even possible? I am looking for someone to point me in the right direction, mostly an API, or a tutorial (or sample code).

Thank you !
Offline noblemaster

« JGO Spiffy Duke »


Medals: 35
Projects: 11


Age of Conquest makes your day!


« Reply #1 - Posted 2006-05-01 19:07:41 »

You could set the mouse cursor to use a different appearance depending on what is attached. Checkout:
Component.setCursor(...).
Toolkit.createCustomCursor(...).

Offline dayrinni

Junior Devvie





« Reply #2 - Posted 2006-05-01 19:28:05 »

Thanks, I'll check it out.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline noblemaster

« JGO Spiffy Duke »


Medals: 35
Projects: 11


Age of Conquest makes your day!


« Reply #3 - Posted 2006-05-01 19:32:10 »

There is also drag/drop, but I have to admit I am not too familiar with it ...

Offline dayrinni

Junior Devvie





« Reply #4 - Posted 2006-05-01 19:47:19 »

I can do drag and drop, but I'm not totally sure how to make it stay 'dragged' until you click the mouse button again.
Offline Kova

Senior Devvie





« Reply #5 - Posted 2006-05-02 00:59:07 »

I'm not sure I understand all, but when you select something from first menu, then you remember it and create custom cursor with that image until you click somewhere else and draw image that you remembered on that location, changing cursor back to normal.
All this is pretty doable, hardest part is custom cursor I think.
Offline dayrinni

Junior Devvie





« Reply #6 - Posted 2006-05-02 06:17:35 »

I shall try to explain again.

I'll use desktop icons as an example. You can click and drag them around and drop them - I can do that in java.

BUT, imagine this. You want to move an icon. So you click it. Then it is attached to your mouse pointer, so your pointer graphic doesn't change. When you move your mouse around, the clicked icon will now move with the mouse pointer. When you click it again, the icon that is attached to your mouse pointer will be released and placed on a new spot on the desktop.

So instead of "click and drag" we are doing "click and drop". To move items you don't have to hold down the mouse bottom anymore.

Does that explain it better?
Offline noblemaster

« JGO Spiffy Duke »


Medals: 35
Projects: 11


Age of Conquest makes your day!


« Reply #7 - Posted 2006-05-02 06:55:46 »

Your explanation was good! I am not sure if we need a drag & drop expert here?

Another solution would be to add a mouse listener to the window/panel: Add a glass pane or something on top.
1. you click on the icon, it is removed from the original panel and attached to the glass pane
2. when you move your mouse, you adjust the position of the icon on the glass pane, so it sits right under the mouse pointer
3. you click again, you remove the icon from the glass pane and put it into the new panel

Offline Anon666

Junior Devvie




aka Abuse/AbU5e/TehJumpingJawa


« Reply #8 - Posted 2006-05-03 22:35:52 »

Its worth noting the drag&drop api is realy badly designed and in some cases simply doesn't function as described.
In particular (on windows atleast) the Image parameter for displaying an Image while a drag operation is in effect doesn't work. (DragSource.startDrag(...))
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1669 views)
2018-06-10 19:43:48

EgonOlsen (1706 views)
2018-06-10 19:43:44

EgonOlsen (1158 views)
2018-06-10 19:43:20

DesertCoockie (1585 views)
2018-05-13 18:23:11

nelsongames (1185 views)
2018-04-24 18:15:36

nelsongames (1709 views)
2018-04-24 18:14:32

ivj94 (2533 views)
2018-03-24 14:47:39

ivj94 (1758 views)
2018-03-24 14:46:31

ivj94 (2835 views)
2018-03-24 14:43:53

Solater (971 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!