javafx中tableView双击行事件

tableView.setRowFactory(new Callback<TableView<SerialData>, TableRow<SerialData>>()
{
    @Override
    public TableRow<SerialData> call(TableView<SerialData> param)
    {
        TableRow<SerialData> row = new TableRow<SerialData>();
        row.setOnMouseClicked(new EventHandler<MouseEvent>()
        {
            @Override
            public void handle(MouseEvent event)
            {
                if (event.getClickCount() == 2 && (! row.isEmpty()) )
                {
                    System.out.println(row.getIndex());
                    SerialData serialData = row.getItem();
                    System.out.println(serialData.getName());
                }
            }
        });
        return row;
    }
});

 

上一篇:JavaFX桌面应用-MVC模式开发,“真香”


下一篇:JavaFX布局神器-SceneBuilder