FULL PRODUCT VERSION :
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Windows 7 x64 SP1
A DESCRIPTION OF THE PROBLEM :
I have a test case, which demonstrates the situation, when the content of a TableView is not displayed properly. The table shows completely white rectangle, while it should show the data and the grid. This happens when I do refresh() after removing most of the columns.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) start the test case
2) scroll the table horizontally to the most right
3) press the button "Hide [1-99]".
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Col 00 with data and grid is shown
ACTUAL -
Col 00 is shown, but there is no data or grid displayed.
One have to click in the table or scroll or touch a column for the content to appear.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class FXTableViewExample10 extends Application {
public static void main(String [] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
TableView<Integer> table = new TableView<>();
table.setFixedCellSize(24);
// rows
table.getItems().addAll(IntStream.range(0, 100).boxed().collect(Collectors.toList()));
// columns & cells
for (int j=0; j<100; j++) {
int colNr = j;
TableColumn<Integer, String> col = new TableColumn<>(String.format("Col %02d", j));
col.setCellValueFactory(feat -> new SimpleStringProperty(String.format("%02d.%02d", colNr, feat.getValue())));
table.getColumns().add(col);
}
Button hide = new Button("Hide [1-99]");
hide.setOnAction(event -> changeVisibility(table, false));
Button show = new Button("Show all");
show.setOnAction(event -> changeVisibility(table, true));
Scene scene = new Scene(new VBox(table, new HBox(hide, show)), 500, 475);
primaryStage.setScene(scene);
primaryStage.show();
}
private void changeVisibility(TableView<?> table, boolean newValue) {
for (int i=1; i<100; i++) {
table.getColumns().get(i).setVisible(newValue);
}
// This is necessary to workaroundJDK-8144500.
Platform.runLater(() -> table.refresh());
}
}
---------- END SOURCE ----------
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Windows 7 x64 SP1
A DESCRIPTION OF THE PROBLEM :
I have a test case, which demonstrates the situation, when the content of a TableView is not displayed properly. The table shows completely white rectangle, while it should show the data and the grid. This happens when I do refresh() after removing most of the columns.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) start the test case
2) scroll the table horizontally to the most right
3) press the button "Hide [1-99]".
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Col 00 with data and grid is shown
ACTUAL -
Col 00 is shown, but there is no data or grid displayed.
One have to click in the table or scroll or touch a column for the content to appear.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class FXTableViewExample10 extends Application {
public static void main(String [] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
TableView<Integer> table = new TableView<>();
table.setFixedCellSize(24);
// rows
table.getItems().addAll(IntStream.range(0, 100).boxed().collect(Collectors.toList()));
// columns & cells
for (int j=0; j<100; j++) {
int colNr = j;
TableColumn<Integer, String> col = new TableColumn<>(String.format("Col %02d", j));
col.setCellValueFactory(feat -> new SimpleStringProperty(String.format("%02d.%02d", colNr, feat.getValue())));
table.getColumns().add(col);
}
Button hide = new Button("Hide [1-99]");
hide.setOnAction(event -> changeVisibility(table, false));
Button show = new Button("Show all");
show.setOnAction(event -> changeVisibility(table, true));
Scene scene = new Scene(new VBox(table, new HBox(hide, show)), 500, 475);
primaryStage.setScene(scene);
primaryStage.show();
}
private void changeVisibility(TableView<?> table, boolean newValue) {
for (int i=1; i<100; i++) {
table.getColumns().get(i).setVisible(newValue);
}
// This is necessary to workaround
Platform.runLater(() -> table.refresh());
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8144500 fixed cell size causes column removing problems and slow rendering
- Resolved