0

I defined a paste method in a controller class, based on the solution given here: How to copy/paste table cells in a TableView. Everything went well, except for one detail: some cells where data is pasted have events that should be triggered but are not.

For example:

public class MyController {

    private TableColumn<MyBean, String> valueColumn;

    ...

    valueColumn.setOnEditCommit(e -> doSomeStuff(e));

    private void doSomeStuff(CellEditEvent<MyBean, String> event) {
        ...
    }

In this example, after user hits ENTER, the doSomeStuff method is called, which is expected behavior.

The problem with the paste method I implemented is that it does not affect the cell, only its content (its ObservableValue). This means of course that after data is pasted, no event is triggered.

My question : is there a way to trigger the same event, or a similar one that will call my doSomeStuff method after pasting data?

Francois
  • 586
  • 2
  • 6
  • 19
  • 1
    Shouldn't be too difficult to create an instance of `CellEditEvent` on your own and pass it to the `handle` method of an event handler, if there is one... – fabian Jun 14 '19 at 02:11
  • short answer: no. you never-ever talk to the cells (they may not even exist), but only to the data – kleopatra Jun 14 '19 at 03:54
  • @fabian I tried your solution and it worked. I created a custom event that, when fired, calls the same method the other event calls. Thanks. – Francois Jun 17 '19 at 13:31

1 Answers1

0

Table View doesn't work as you think. If you want to have a fully customizable structure, use a grid pane. It is hard to create one, but after you make it look like a table, you have many more options to customize. I did that I a recent project where I was needed to insert a table inside a cell. It was much more easier with a gridpane and textfields.