Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
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 2043 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  
 
 

 
Ecumene (108 views)
2017-09-30 02:57:34

theagentd (135 views)
2017-09-26 18:23:31

cybrmynd (245 views)
2017-08-02 12:28:51

cybrmynd (240 views)
2017-08-02 12:19:43

cybrmynd (238 views)
2017-08-02 12:18:09

Sralse (252 views)
2017-07-25 17:13:48

Archive (864 views)
2017-04-27 17:45:51

buddyBro (1007 views)
2017-04-05 03:38:00

CopyableCougar4 (1566 views)
2017-03-24 15:39:42

theagentd (1373 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!