ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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?
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?
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.