A
A
Anton @ Lyalin2017-04-10 12:20:10
Java
Anton @ Lyalin, 2017-04-10 12:20:10

How to display data in the table of a new window?

The controller of the main class, in which a new window is called by clicking on the button:
it passes the text from the text field

public void actionFilter(ActionEvent actionEvent) {
        Filter filter = new Filter(loadTextArea.getText());
        filter.print();
        FilterMain filterMain = new FilterMain();
        try {
            filterMain.start(new Stage());
        } catch (Exception ignored) {
        }
    }

The controller of the second window, in which there is a TableView and where you want to display the text:
@FXML
    public TableView<Filter> tableView;

    @FXML
    public TableColumn<Filter, String> columnWord;

    @FXML
    public TableColumn<Filter, Integer> columnFrequency;

    @Override
    public void initialize(URL location, ResourceBundle resources) {

        columnWord.setCellValueFactory(new PropertyValueFactory<>("word"));
        columnFrequency.setCellValueFactory(new PropertyValueFactory<>("number"));

        tableView.setItems(filters());
    }

    private ObservableList<Filter> filters(){
        Filter filter = new Filter();
        return filter.observableList();
    }

Where is the mistake? Even the window does not start, it seems to be normal, I pass the sheet from the Filter class, which is passed to the initialize method for output to the table.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question