2015-10-15 60 views
0

我有一個javafx程序的問題,我用一些列創建tableview,其中一個可以填充很多文本,所以我想在單元格中有一個滾動條比顯示的寬度長。 目前所有創建該特定列中的代碼是JavaFX水平滾動條到TableView的單元格

 @FXML 
private TableColumn<ARule,String> antCol; 

customTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); 
customTable.setEditable(true); 


antCol.prefWidthProperty().bind(customTable.widthProperty().multiply(0.43)); 
antCol.setCellValueFactory(new PropertyValueFactory<ARule, String>("antecedente")); 

當尺寸爲總表的一部分,但是,當文本越大則該單元的尺寸我不能獲得水平滾動。

感謝您的幫助。

+0

使用自定義電池廠呈現在'textArea'單元中的數據。 – Kachna

+0

你能更具體嗎?我可以ovveride到setCellFactory的回調,但我怎麼可以呈現爲textArea?不管怎樣,謝謝。 – DeBiA

回答

0

我不知道下面的代碼片段可以幫助:

antCol.setCellFactory(col -> { 
        TableCell<ARule, String> cell = new TableCell<ARule, String>() { 

         @Override 
         protected void updateItem(String item, boolean empty) { 
          super.updateItem(item, empty); 
          if (empty) { 
           setText(null); 
           setGraphic(null); 
          } else { 
           setText(null); 
           TextArea textArea = new TextArea(); 
           textArea.setPrefColumnCount(4); 
           textArea.setPrefRowCount(1); 
           textArea.setText(item); 
           setGraphic(textArea); 
          } 

         } 

        }; 
        return cell; 
       }); 
+0

這個答案就是我所做的,TableCell中有一個錯誤 => TableCell , 唯一的問題是在視覺層面上不完美的集成,你會看到TextArea的邊界和細胞的。 無論如何,謝謝! – DeBiA