Java Swing Drag and Drop with popup dialog?

If you want to be able to possibly drag-and-drop items, as well as move/copy them programatically, you need to make sure you have a proper model set up which backs the view This means you shouldn't be coding your business logic directly into the GUI code. The model should be simple and independent, focusing on the actual task of managing the data. In your case, you it sounds like you just need to hold some collections of objects and provide methods which move/copy objects from one collection to the other.

The code which does this is called the controller (MVC - pardon me if you are already familiar with this pattern). The controller will then update the GUI to reflect the changes. Similarly, your drag-and-drop will trigger a controller action which performs a similar action on the model.

If you want to be able to possibly drag-and-drop items, as well as move/copy them programatically, you need to make sure you have a proper model set up which backs the view. This means you shouldn't be coding your business logic directly into the GUI code. The model should be simple and independent, focusing on the actual task of managing the data.In your case, you it sounds like you just need to hold some collections of objects and provide methods which move/copy objects from one collection to the other.

The code which does this is called the controller (MVC - pardon me if you are already familiar with this pattern). The controller will then update the GUI to reflect the changes. Similarly, your drag-and-drop will trigger a controller action which performs a similar action on the model.

Thanks for the clear and concise answer. I was thinking much along the same lines once I dug deep enough into the TransferHandler and Transferable documentation/JavaDoc. The problem I'm having is one with timing (and with side effects) in the controller/view layer as affected by the current design which operates on the AWT event thread.

– Daniel May 16 at 20:27 Best practise states the model should be thread-safe, but if it's only modified from the EDT then you shouldn't have any problems if it isn't. You obviously know about the EDT rules. I would need specific examples if you need further help.

– BoffinbraiN May 16 at 23:02.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions