LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-03-2009, 09:04 PM   #1
manolakis
Member
 
Registered: Nov 2006
Distribution: xubuntu
Posts: 464

Rep: Reputation: 37
Moving Java Drawing Objects


Hi there,

I have made a Java GUI which has a panel where I draw different kind of objects like circles, rectagulars, lines, etc. I would like to ask if anyone knows how is it possible to be able to select these objects with the mouse and drag them to a different location? Where I really stack is at the draging.
Any ideads?

Thank you.
 
Old 10-03-2009, 10:27 PM   #2
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by manolakis View Post
Hi there,

I have made a Java GUI which has a panel where I draw different kind of objects like circles, rectagulars, lines, etc. I would like to ask if anyone knows how is it possible to be able to select these objects with the mouse and drag them to a different location? Where I really stack is at the draging.
Any ideads?

Thank you.
You need to create a system of relocatable, transparent, borderless windows, windows whose only opaque content is the lines or geometric objects. Then you can select them with the mouse and move them around.

Be sure to put in a way to change the z-order of the windows. That is a standard and essential feature of this kind of drawing program.
 
Old 10-05-2009, 04:45 PM   #3
manolakis
Member
 
Registered: Nov 2006
Distribution: xubuntu
Posts: 464

Original Poster
Rep: Reputation: 37
lutusp,

Because I do not know everything about Java GUIs could you please give an example of what you mean. I can not to do that by having a sub-class of a JPanel and overwriting the paintComponent(Graphics g) method? What exactly windows do I have to use? Could you give me example of Java classes that you mean?

Thank you very much.
 
Old 10-05-2009, 06:14 PM   #4
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by manolakis View Post
lutusp,

Because I do not know everything about Java GUIs could you please give an example of what you mean. I can not to do that by having a sub-class of a JPanel and overwriting the paintComponent(Graphics g) method? What exactly windows do I have to use? Could you give me example of Java classes that you mean?

Thank you very much.
Java Swing

You need to learn this stuff just like everyone else, by browsing, reading, learning, and coding. Good luck.
 
Old 10-05-2009, 11:37 PM   #5
Fallen_Demon
LQ Newbie
 
Registered: Sep 2009
Location: Australia
Distribution: Ubuntu
Posts: 13

Rep: Reputation: 2
I recently did this. Basically, you want a generic shape object and a method in it that can detect whether a given point is inside it. Then, you want a "drag" method that you can use to change the co-ordinates of the model. If you've done MVC right it should be simple to decouple it to the point where this isn't a pain
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem copying drawing objects/selecting rows in OpenOffice Writer amrtuti Linux - Software 0 03-24-2009 06:40 AM
LXer: Java Data Objects and Service Data Objects in SOA LXer Syndicated Linux News 0 01-17-2009 06:10 AM
Drawing Triangles in Java chrisk5527 Programming 3 03-17-2007 09:34 AM
java objects zaicheke Programming 3 03-23-2005 06:21 AM
Objects in Java? mikeshn Programming 0 06-11-2002 10:21 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration