Code to reproduce:
package javafxtable;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.stage.Stage;
public class JavaFXTable extends Application {
public static void main(String[] args) {
Application.launch(JavaFXTable.class, args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Table issues");
ObservableList<Record> records = FXCollections.observableArrayList();
for (int i = 1; i <= 100; i++) {
Record r = new Record((long)i, "Name "+i);
records.add(r);
}
Collections.shuffle(records);
TableView<Record> root = new TableView<Record>();
TableColumn<Long> columnId = new TableColumn<Long>("ID");
columnId.setProperty("id");
TableColumn<String> columnName = new TableColumn<String>("Name");
columnName.setProperty("name");
root.getColumns().addAll(columnId, columnName);
root.setItems(records);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setVisible(true);
}
public static class Record {
private final Long id;
private final String name;
public Record(Long id, String name) {
this.id = id;
this.name = name;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
}
}
Steps:
1. initial state - see picture1
2. click on first column - ascendant sorting by first column see picture2
3. click on first column - descendant sorting by first column see picture3
4. click on first column - unsorted (initial state) see picture4
Expected: initial state (unsorted)
Actual: last sort order - bug.
package javafxtable;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.stage.Stage;
public class JavaFXTable extends Application {
public static void main(String[] args) {
Application.launch(JavaFXTable.class, args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Table issues");
ObservableList<Record> records = FXCollections.observableArrayList();
for (int i = 1; i <= 100; i++) {
Record r = new Record((long)i, "Name "+i);
records.add(r);
}
Collections.shuffle(records);
TableView<Record> root = new TableView<Record>();
TableColumn<Long> columnId = new TableColumn<Long>("ID");
columnId.setProperty("id");
TableColumn<String> columnName = new TableColumn<String>("Name");
columnName.setProperty("name");
root.getColumns().addAll(columnId, columnName);
root.setItems(records);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setVisible(true);
}
public static class Record {
private final Long id;
private final String name;
public Record(Long id, String name) {
this.id = id;
this.name = name;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
}
}
Steps:
1. initial state - see picture1
2. click on first column - ascendant sorting by first column see picture2
3. click on first column - descendant sorting by first column see picture3
4. click on first column - unsorted (initial state) see picture4
Expected: initial state (unsorted)
Actual: last sort order - bug.