javafx-未捕获表视图鼠标事件

javafx-未捕获表视图鼠标事件,java,javafx,mouseevent,Java,Javafx,Mouseevent,我的fxml中有一个TableView。在控制器中,此表映射为@FXML注释 @FXML TableView<BankMovement> table; 最后总是在控制器中我有以下方法 @FXML private void handleRowSelect(MouseEvent event){ Document row = table.getSelectionModel().getSelectedItem(); if (row == null) return;

我的fxml中有一个TableView。在控制器中,此表映射为@FXML注释

@FXML
TableView<BankMovement> table;
最后总是在控制器中我有以下方法

@FXML
private void handleRowSelect(MouseEvent event){
    Document row = table.getSelectionModel().getSelectedItem();
    if (row == null) return;
    if(row != temp){
        temp = row;
        lastClickTime = new Date();
    } else if(row == temp) {
        Date now = new Date();
        long diff = now.getTime() - lastClickTime.getTime();
        if (diff < 300){ 
            System.out.println("Edit dialog");
            System.out.print(row.getDescription());
        } else {
            lastClickTime = new Date();
            System.out.print(row.getFile());

        }
    }
}
@FXML
私有无效HandlerRowselect(MouseeEvent事件){
文档行=table.getSelectionModel().getSelectedItem();
if(row==null)返回;
如果(行!=临时){
温度=行;
lastClickTime=新日期();
}else if(行==temp){
现在日期=新日期();
long diff=now.getTime()-lastClickTime.getTime();
if(diff<300){
System.out.println(“编辑对话框”);
System.out.print(row.getDescription());
}否则{
lastClickTime=新日期();
System.out.print(row.getFile());
}
}
}
这里是将数据绑定到表的位置

@Override
public void initializeTable() {
    table.setItems(subList());
    colId.setCellValueFactory(new PropertyValueFactory<>("idDocument"));
    colIdCategory.setCellValueFactory(d -> new SimpleStringProperty(d.getValue().getCategory().getName()));
    colIdCategoryChild.setCellValueFactory(d -> new SimpleStringProperty(d.getValue().getCategoryChild().getName()));
    colIdDocument.setCellFactory(getFileCellFactory());
    colIdDocument.setCellValueFactory(new PropertyValueFactory<>("file"));
    colIdDescription.setCellValueFactory(new PropertyValueFactory<>("description"));
    colIdDate.setCellValueFactory(d -> new SimpleStringProperty(Utils.localTimeToItalianDate(d.getValue().getDocumentDate())));
}
@覆盖
public void initializeTable(){
table.setItems(subList());
colId.setCellValueFactory(新的PropertyValueFactory(“idDocument”);
colIdCategory.setCellValueFactory(d->new SimpleStringProperty(d.getValue().getCategory().getName());
colIdCategoryChild.setCellValueFactory(d->new SimpleStringProperty(d.getValue().getCategoryChild().getName());
setCellFactory(getFileCellFactory());
colIdDocument.setCellValueFactory(新的PropertyValueFactory(“文件”);
colIdDescription.setCellValueFactory(新属性ValueFactory(“说明”);
colIdDate.setCellValueFactory(d->new SimpleStringProperty(Utils.LocalTimeToAliandate(d.getValue().getDocumentDate()));
}
即使我点击表格,我也不会输入handleRowSelect方法

我的印象是,当我单击行时,对单元格的单击是管理的,而不是在行上。好像事件没有传播

这是fxml

<AnchorPane minWidth="-Infinity"  prefHeight="900.0" prefWidth="1510.0" styleClass="background-white" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="MyController">
    <children>
        <VBox prefHeight="886.0" prefWidth="1465.0" style="-fx-min-width: 100%;" AnchorPane.bottomAnchor="4.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="330.0" AnchorPane.topAnchor="10.0">
            <children>
                <TitledPane animated="false" minHeight="-Infinity" minWidth="-Infinity" prefHeight="880.0" prefWidth="1465.0" text="%app.pane.document">
                    <content>
                        <VBox minWidth="-Infinity" prefHeight="815.0" prefWidth="1474.0">
                            <children>
                                <TableView onMouseReleased="#handleRowSelect" fx:id="table" minHeight="-Infinity" minWidth="-Infinity" prefHeight="746.0" prefWidth="1450.0">
                                    .......
                                    <padding>
                                        <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
                                    </padding>
                                </TableView>
                                <Pagination fx:id="pagination" prefHeight="73.0" prefWidth="1450.0" />
                            </children>
                        </VBox>
                    </content>
                </TitledPane>
            </children>
        </VBox>
    </children>
</AnchorPane>

.......

请包括您的实际相关FXML。首先,您不希望在
#
和方法名称之间留有空格。与其自己计算两次单击之间的时间,不如使用该方法来确定用户是否双击。@xtratic这是复制和过去的错误。我添加了fxml。您能提供一个演示该问题的示例吗?我在重现问题时遇到问题,
MouseEvent
为我在
TableView
中出现气泡。注意,我使用的是JavaFX13。我更改了事件,现在它可以工作了。事件已被单击
<AnchorPane minWidth="-Infinity"  prefHeight="900.0" prefWidth="1510.0" styleClass="background-white" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="MyController">
    <children>
        <VBox prefHeight="886.0" prefWidth="1465.0" style="-fx-min-width: 100%;" AnchorPane.bottomAnchor="4.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="330.0" AnchorPane.topAnchor="10.0">
            <children>
                <TitledPane animated="false" minHeight="-Infinity" minWidth="-Infinity" prefHeight="880.0" prefWidth="1465.0" text="%app.pane.document">
                    <content>
                        <VBox minWidth="-Infinity" prefHeight="815.0" prefWidth="1474.0">
                            <children>
                                <TableView onMouseReleased="#handleRowSelect" fx:id="table" minHeight="-Infinity" minWidth="-Infinity" prefHeight="746.0" prefWidth="1450.0">
                                    .......
                                    <padding>
                                        <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
                                    </padding>
                                </TableView>
                                <Pagination fx:id="pagination" prefHeight="73.0" prefWidth="1450.0" />
                            </children>
                        </VBox>
                    </content>
                </TitledPane>
            </children>
        </VBox>
    </children>
</AnchorPane>