Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a Drag and Drop Interface in Java

I trying to create some sort of interface from scratch for objects that can be dragged and dropped using some sort of EventListener. I can't directly use any of javax.swing classes because I'm not dealing with Components; however, I have a made my own custom ActionEvent class by extending EventObject, so doing something like is fair play for me.

This is for a game engine, and more specifically for an inventory in a game. The items that are dragged around are Sprites, but I want this to be general enough to allow a very basic Class to be dragged. The item holder is called ItemHolder and contains a Sprite.

I'd just like some general advice on this; perhaps some links to examples. This is probably not going to be a very popular topic in Java, so something in a different language is fine too.

Thank you.

like image 881
helsont Avatar asked Feb 27 '26 12:02

helsont


1 Answers

If you're not doing this in a browser, then there are ways to do this using Swing user interface.

If you're developing a Java application server side, using a web browser, my recommendation is to use the Yahoo User Interface (YUI) framework or the jQuery framework and their drag and drop features. There are so many cross browser compatibility issues you'll run into while developing something yourself if you want it to work in all browsers, it probably won't be worth your time if there are resources already available. Just a suggestion.

like image 105
MacGyver Avatar answered Mar 02 '26 01:03

MacGyver



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!