Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 带拖放功能的网格窗格位置_Java_Javafx - Fatal编程技术网

Java 带拖放功能的网格窗格位置

Java 带拖放功能的网格窗格位置,java,javafx,Java,Javafx,我想在网格窗格中进行拖放操作,拾取的元素将被拖放到我们拖放它的单元格中。但是我找不到一种方法来获取它应该被删除到的单元格的列和行 下面是SetOnDragDrop内部的外观: ImageView ivPicked = new ImageView(e.getDragboard().getImage());//We get the ImageView from the Dragboard int col = /*Put code to get the column here*/; int row =

我想在网格窗格中进行拖放操作,拾取的元素将被拖放到我们拖放它的单元格中。但是我找不到一种方法来获取它应该被删除到的单元格的列和行

下面是SetOnDragDrop内部的外观:

ImageView ivPicked = new ImageView(e.getDragboard().getImage());//We get the ImageView from the Dragboard
int col = /*Put code to get the column here*/;
int row = /*Put code to get the row here*/;
grid.add(ivPicked,col,row);//Add it to the GridPane
e.consume();
有人有主意吗?
谢谢:D

您需要在网格窗格中填充每个网格单元格中的一些内容(使用某种类型的
窗格
:可能是
堆栈窗格
),然后用每个单元格的内容注册拖放处理程序。所有内容都已创建,我实际上想将其放到特定位置,但我不知道如何操作。是否需要为每个单元格创建一个节点?是的,为每个单元格创建一个节点。如果您使用类似于
StackPane
,则只需将图像视图添加到发生拖放的堆栈窗格中即可。好的,我将尝试此操作,我会让您知道结果!非常感谢。