Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (762)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (846)
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 1791 times)
0 Members and 1 Guest are viewing this topic.
Offline DAT64X

Senior Newbie




Java games rock!


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

Hi,

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.

Thanks!
DAT
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!

http://wiki.java.net/bin/view/Games/JeffFAQ
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 (359 views)
2018-06-10 19:43:48

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

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

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

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

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

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

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

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

Solater (417 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

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
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!