2016-07-29 21 views
0

私は現在javafxで作業しており、深刻な問題があります。私は、テーブルビューで動的に作成したボタンの行のインデックスを取得する方法を見つけることができません。javafxのテーブルビューの動的作成ボタンの行を知る方法

誰かが私を助けることができたら、それは非常に役に立ちます。 handle()方法で

this.clmColumn.setCellFactory((TableColumn<?, ?> column) -> { 
      return new TableCell<?, ?>() { 
       @Override 
       protected void updateItem(? item, boolean empty) { 

        super.updateItem(item, empty); 
        if (!empty) { 
         final HBox hbox = new HBox(5); 
         final VBox vbox = new VBox(5); 
         Label label = new Label(item.toString()); 
         final Button btnMais = new Button("+"); 
         btnMais.setMinSize(25, 25); 
         final TableCell<?, ?> c = this; 
         btnMais.setOnAction(new EventHandler<ActionEvent>() { 
          @Override 
          public void handle(ActionEvent event) { 
           // At this point i want to select the current ROW of the button that i pressed on the tableview. 

          } 
         }); 
         final Button btnMenos = new Button("-"); 
         btnMenos.setMinSize(25, 25); 
         btnMenos.setOnAction(new EventHandler<ActionEvent>() { 
          @Override 
          public void handle(ActionEvent event) { 
           if (getItem() > 1) { 
            // At this point i want to select the current ROW of the button that i pressed on the tableview. 

           } 
          } 
         }); 
         final Button btnRemover = new Button("Remover"); 
         btnRemover.setFont(new Font(8)); 
         btnRemover.setOnAction(new EventHandler<ActionEvent>() { 
          @Override 
          public void handle(ActionEvent event) { 
           // At this point i want to select the current ROW of the button that i pressed on the tableview. 

          } 
         }); 
         vbox.getChildren().add(hbox); 
         vbox.getChildren().add(btnRemover); 
         hbox.getChildren().add(btnMais); 
         hbox.getChildren().add(label); 
         hbox.getChildren().add(btnMenos); 
         hbox.setAlignment(Pos.CENTER); 
         vbox.setAlignment(Pos.CENTER); 
         setGraphic(vbox); 
        } else { 
         setGraphic(null); 
        } 

       } 
      }; 
     }); 

答えて

0

あなたは型パラメータで全体のより具体的な種類を使用する場合は、より具体的な形でObjectを置き換えることができ

Object row = getTableView.getItems().get(getIndex()); 

を行うことができます。

+0

ありがとうございました!これは正解です! – helpplz

関連する問題