Good day. There is a tableview with 3 columns. Suppose 200-300 rows are written to the first 2 columns, null is passed to the 3rd column at this moment. Clearly:

usersData.add(new dataTable(i+". "+art, tit, null+"\n")); 

During the program execution, a text file of 5-10k + lines is written to the auralist.

 BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("text.txt")), StandardCharsets.UTF_8)); while ((str = br.readLine()) != null) { list.add(str+"\n"); 

Actually these lines from the file need to be inserted into the 3rd column of the TableView, but since this column is filled with null, all the rows from this file are written below. Visually, in the program interface, it looks like an empty n-th number of rows in the 3rd column (which we first filled, passing null to the 3rd column) and the lines from the file already begin to follow.

Question: how to start writing these lines from the file again to the 1st row of the TableView, without overwriting the remaining 2 columns?

PS Is it possible to implement horizontal text scrolling for each column separately from the rest? or something like that.

    1 answer 1

    Here is an example of creating a table and its columns:

      TableView<LobbiItems> tableView; TableColumn<LobbiItems, String> tableColumnHost = new TableColumn<>("Хост"); TableColumn<LobbiItems, String> tableColumnEnemy = new TableColumn<>("Соперник"); TableColumn<LobbiItems, Circle> tableColumnStatus = new TableColumn<>("Статус"); tableColumnHost.setCellValueFactory(new PropertyValueFactory<>("name")); tableColumnEnemy.setCellValueFactory(new PropertyValueFactory<>("secondName")); tableColumnStatus.setCellValueFactory(new PropertyValueFactory<>("statusCircle")); tableView = new TableView<>(); tableView.getColumns().addAll(tableColumnHost, tableColumnEnemy, tableColumnStatus); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); 

    class LobbiItems which is indicated by the tableview

     private StringProperty name; private StringProperty secondName; private Circle statusCircle; public LobbiItems(String name, String secondName,color) { this.name = new SimpleStringProperty(name); this.secondName = new SimpleStringProperty(secondName); this.statusCircle = new Circle(5, 5, 5, color); } public void setColor(Color color) { statusCircle.setFill(color); } public Circle getStatusCircle() { return statusCircle; } public void setStatusCircle(Circle statusCircle) { this.statusCircle = statusCircle; } public String getName() { return name.get(); } public StringProperty nameProperty() { return name; } public void setName(String name) { this.name.set(name); } public String getSecondName() { return secondName.get(); } public StringProperty secondNameProperty() { return secondName; } public void setSecondName(String secondName) { this.secondName.set(secondName); } 

    To add or change data:

      //изменение tableView.getItems().forEach(lobbiItems -> { //теперь все элементы таблицы поменяют первую строчку на "Другой текст" lobbiItems.setName("Другой текст"); }); //добавление tableView.getItems.addAll(/*наш элемент LobbiItems*/);