Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8301745 | jfx17.0.7 | Johan Vos | P3 | Resolved | Fixed |
ADDITIONAL SYSTEM INFORMATION :
Running on Windows 10, OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.1+9)
A DESCRIPTION OF THE PROBLEM :
Using a touch-enabled device (or add the JVM argument -Dcom.sun.javafx.touch=true), the virtual flow scrolls all the way to the left when the scrollbar disappears. It allows scrolling to the right however it only stays for a second or two before the horizontal scrollbar gets reset to 0 (when the scrollbar disappears from inactivity, it gets reset to 0). From closer inspection of the code, it seems this is caused by the method updateHbar(), in .../modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java. The method checks if the hbar is visible and if it is not, it gets set to 0
if (hbar.isVisible()) {
clipView.setClipX(hbar.getValue());
} else {
// all cells are now less than the width of the flow,
// so we should shift the hbar/clip such that
// everything is visible in the viewport.
clipView.setClipX(0);
hbar.setValue(0);
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
With the parameter (-Dcom.sun.javafx.touch=true) as a JVM argument, run an application containing a table view, where the window is smaller than the table, thus causing a horizontal scrollbar, drag the scrollbar all the way to the right and release it and wait until the scrollbar disappears.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When the scrollbar disappears, the table should remain as it was in the position you scrolled to.
ACTUAL -
When the scrollbar disappears, the table is scrolled to the beginning (hbar value of 0).
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ObservableValue;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Callback;
import java.util.ArrayList;
public class Main extends Application {
int columns = 5;
int numRows = 15;
StackPane root = new StackPane();
@Override
public void start(Stage primaryStage) {
Scene scene = new Scene(root, 200, 400);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
TableView table = getNewTestTableview();
root.getChildren().add(table);
}
public TableView<StringProperty[]> getNewTestTableview() {
TableView<StringProperty[]> tableView = new TableView<>();
for (int i = 0; i < columns; i++) {
final int colIndex = i;
TableColumn<StringProperty[], String> col = new TableColumn<>();
col.setCellValueFactory(new Callback<>() {
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<StringProperty[], String> param) {
return param.getValue()[colIndex];
}
});
tableView.getColumns().add(col);
}
ArrayList<StringProperty[]> rows = new ArrayList<>();
for (int i = 0; i < numRows; i++) {
StringProperty[] row = new StringProperty[columns];
for (int j = 0; j < columns; j++) {
row[j] = new SimpleStringProperty("Row " + i + " Col " + j);
}
rows.add(row);
}
tableView.getItems().addAll(rows);
return tableView;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
Running on Windows 10, OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.1+9)
A DESCRIPTION OF THE PROBLEM :
Using a touch-enabled device (or add the JVM argument -Dcom.sun.javafx.touch=true), the virtual flow scrolls all the way to the left when the scrollbar disappears. It allows scrolling to the right however it only stays for a second or two before the horizontal scrollbar gets reset to 0 (when the scrollbar disappears from inactivity, it gets reset to 0). From closer inspection of the code, it seems this is caused by the method updateHbar(), in .../modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java. The method checks if the hbar is visible and if it is not, it gets set to 0
if (hbar.isVisible()) {
clipView.setClipX(hbar.getValue());
} else {
// all cells are now less than the width of the flow,
// so we should shift the hbar/clip such that
// everything is visible in the viewport.
clipView.setClipX(0);
hbar.setValue(0);
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
With the parameter (-Dcom.sun.javafx.touch=true) as a JVM argument, run an application containing a table view, where the window is smaller than the table, thus causing a horizontal scrollbar, drag the scrollbar all the way to the right and release it and wait until the scrollbar disappears.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When the scrollbar disappears, the table should remain as it was in the position you scrolled to.
ACTUAL -
When the scrollbar disappears, the table is scrolled to the beginning (hbar value of 0).
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ObservableValue;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Callback;
import java.util.ArrayList;
public class Main extends Application {
int columns = 5;
int numRows = 15;
StackPane root = new StackPane();
@Override
public void start(Stage primaryStage) {
Scene scene = new Scene(root, 200, 400);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
TableView table = getNewTestTableview();
root.getChildren().add(table);
}
public TableView<StringProperty[]> getNewTestTableview() {
TableView<StringProperty[]> tableView = new TableView<>();
for (int i = 0; i < columns; i++) {
final int colIndex = i;
TableColumn<StringProperty[], String> col = new TableColumn<>();
col.setCellValueFactory(new Callback<>() {
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<StringProperty[], String> param) {
return param.getValue()[colIndex];
}
});
tableView.getColumns().add(col);
}
ArrayList<StringProperty[]> rows = new ArrayList<>();
for (int i = 0; i < numRows; i++) {
StringProperty[] row = new StringProperty[columns];
for (int j = 0; j < columns; j++) {
row[j] = new SimpleStringProperty("Row " + i + " Col " + j);
}
rows.add(row);
}
tableView.getItems().addAll(rows);
return tableView;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8301745 With Touch enabled devices scrollbar disappears and the table is scrolled to the beginning
- Resolved