小编ash*_*ens的帖子

JavaFX TableView scrollTo()导致错误的行开始编辑

我有一个可编辑的TableView,其中一个按钮添加了一个新行,然后在该行的第一列调用table.edit().当用户想要添加一个将不在视口中的行时,该表会在视口中滚动新行并开始编辑.但是,调用table.scrollTo(newRow)会导致各种错误行为.该行进入视图,但只有部分时间进入编辑.似乎发生的最多的是视口中的第一行开始编辑而不是新添加的行.这将发生在将在视图中添加的行以及将在视图外的行.

我的代码:

import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellEditEvent;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;


public class TableViewScrollToTest extends Application {

    private final TableView<Person> table = new TableView<>();
    private final ObservableList<Person> data = FXCollections.observableArrayList();
    private final HBox hb = new HBox();
    private final Button addButton = new Button("_Add");
    private int seq = 0;

    @Override
    public void start(Stage …
Run Code Online (Sandbox Code Playgroud)

scrollto tableview javafx-8

2
推荐指数
1
解决办法
1703
查看次数

标签 统计

javafx-8 ×1

scrollto ×1

tableview ×1