Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swing drag and drop [closed]

I would like to implement a game board in swing (needs to be a table, though about either jtable or gridlayout etc ...) where I will be able to drag and drop a picture on to this game board and all the cells that the picture fell on will get a notification that they were chosen.

Can anyone help with that? how do I get a couple of cells in a table know that an object was dropped on them?

like image 960
Jake Avatar asked Dec 19 '11 14:12

Jake


People also ask

What is drag and drop in Java Swing?

Java Swing Tutorial - Java Swing Drag and Drop. Drag and drop (DnD) is a way to transfer data in an application. DnD allows us to transfer data by dragging a component and dropping it onto another component. The component dragged is called the drag source; it supplies the data to be transferred.

What is a droptarget in swing?

A DropTarget is an object responsible for accepting drops in an drag and drop operation. A Transferable encapsulates data being transferred. The transferred data can be of various type. A DataFlavor object provides information about the data being transferred. Several Swing components have already a built-in support for drag and drop operations.

What is drag and drop in DND?

Drag and drop DnD is a way to transfer data in an application by dragging a component and dropping it onto another component. The component that is dragged is called the drag source; it supplies the data to be transferred. The component being dropped is called the drop target; it is the receiver of the data.

What is drag and drop in web development?

Drag and drop (DnD) is a way to transfer data in an application. DnD allows us to transfer data by dragging a component and dropping it onto another component.


2 Answers

Have a look at this tutorial.

like image 186
tobiasbayer Avatar answered Oct 03 '22 18:10

tobiasbayer


I think you have to spent some time with Google. I found the following with a little time with Google.

  • Introduction to DnD
  • How to drag and drop with Java 2, Part 1
  • How to drag and drop with Java 2, Part 2
  • Drag and Drop Effects

Hope this helps :)

like image 20
Jomoos Avatar answered Oct 03 '22 19:10

Jomoos