JavaFX - TextArea reflection of Table cell (like in Excel)

152 Views Asked by At

I'm using JavaFX (With jfoenix) to build my application with SceneBuilder for designing.

I want to build a textview reflection for a table cell, something like in Microsoft Excel (Allow the user to more easily edit the text)

  1. When the user will click/type on some cell in the table, The TextArea will immediately update with the cell text
  2. The opposite - When the user will type in the TextArea, The cell will update on every pressed key.

What have I done until now?

  1. Create the JFXTreeTableView with all the info.
  2. Create the TextView.
  3. Update the TextView when the user choose (or finish the edit cell) some cell on the table - the code is below.

What I have not success to do until now?

  1. Update the cell when the user edit the TextArea (On every change).
  2. Update the TextView on every change of the cell editing.

    treeView.setOnMousePressed(e -> {

                if (e.isPrimaryButtonDown()) {
                    updateTextArea();
                    updateDetailsText();
                }
            }); 
    
    
     private void updateTextArea() {
        TreeTableView.TreeTableViewFocusModel<ModelTable> tfm = treeView.getFocusModel();
        TreeTablePosition<ModelTable, ?> tablePosition = tfm.getFocusedCell();
        TreeTableColumn<ModelTable, ?> tableColumn = tablePosition.getTableColumn();
        int rowIndex = treeView.getFocusModel().getFocusedCell().getRow();
        String data = tableColumn.getCellData(rowIndex).toString();
        edit_cell_text.setText(data.toString()) }
    

I could not find any example/clue to anything like this on the net, I'd love to know if it's possible.

Thanks a lot!

0

There are 0 best solutions below