JavaFX之TableView的TableRow

TableRow

通过TableView的setRowFactory,对行的双击进行操作 

tableView.setRowFactory(new Callback, TableRow>() {    
           @Override    
           public TableRow call(TableView param) {    
               return new TableRowControl();    
           }    
       });    
class TableRowControl extends TableRow {    
    
        public TableRowControl() {    
            super();    
            this.setOnMouseClicked(new EventHandler() {    
                @Override    
                public void handle(MouseEvent event) {    
                    if (event.getButton().equals(MouseButton.PRIMARY)    
                            && event.getClickCount() == 2    
                            && TableRowControl.this.getIndex() < tableView.getItems().size()) {    
                          //doSomething    
                    }    
                }    
            });    
        }    
    }    

 

你可能感兴趣的:(javafx)