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 (855)
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  
  Dragging an object from one panel to another  (Read 1828 times)
0 Members and 1 Guest are viewing this topic.
Offline DAT64X

Senior Newbie

Java games rock!

« Posted 2003-04-14 17:46:19 »


I'm trying to make a JFrame that consists of 2 JPanels.  The left panel has a list of buttons the user can press, and the right panel is a canvas for drawing graphics.  Let's say one of the buttons on the left panel is "place a square" such that if I press the button, I should be able to then move my mouse over to the canvas panel, and the moment my mouse enters the canvas panel region, a pre-drawn square will follow my mouse around.  I can then move my mouse and left-click to "drop" the square on the location of the panel I want.

I know there are mouse motion listeners available, but I was wondering if anyone had any tips, advice, or links to demos with source code that implements this functionality.

Offline Jeff

JGO Coder

Got any cats?

« Reply #1 - Posted 2003-04-21 17:35:59 »

Look at custom cursors.  i believe this is what you wan't.  (Java supports Drag andf Drop but that really doesnt sound like what you are trying to do and woudl be over-kill.)

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!
Offline Harley Rana

Junior Devvie

Java games rock!

« Reply #2 - Posted 2003-04-23 23:06:16 »

Mabye in the drawing panel you've got a list of shapes.  When you click the new button you'd create a temp shape, and move its position with the cursor using mouse motion listener.  When the mouse button is presses to place the shape, add it to the shape list and stop moving its position.
Pages: [1]
  ignore  |  Print  

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

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

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

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

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

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

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

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

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

Solater (905 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 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‑
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!