-
Bug
-
Resolution: Unresolved
-
P4
-
8u20
-
Windows 7 64bit, JDK 8u20 Build b23
JavaFX stops rendering of the Scene if a RuntimeException occurs in CellFactory:
=======================================
RuntimeException in TableView
=======================================
import javafx.animation.PauseTransition;
import javafx.application.Application;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Test extends Application {
@Override
public void start(Stage stage) throws Exception {
VBox vBox = new VBox(20);
// Create independent ListView
ListView<String> listView = new ListView<>();
vBox.getChildren().add(listView);
// Create TableView
TableView<String> tableView = new TableView<String>();
TableColumn<String, String> tableColumn = new TableColumn<String, String>("Heading");
tableColumn.setCellValueFactory(v -> {
return new SimpleObjectProperty<String>(v.getValue());
});
tableColumn.setCellFactory((TableColumn<String, String> param) -> {
return new TableCell<String, String>() {
@Override
protected void updateItem(String item, boolean empty) {
if (item != null) {
setGraphic(new Label(item));
if (item.equals("Probematic")) {
throw new RuntimeException("Unexpected RuntimeException");
}
} else {
setGraphic(null);
}
}
};
});
tableView.getColumns().add(tableColumn);
vBox.getChildren().add(tableView);
// Add data to TableView
ObservableList<String> data = FXCollections.observableArrayList();
PauseTransition dataAddition1 = new PauseTransition(Duration.seconds(3));
dataAddition1.setOnFinished(e -> data.setAll("Item 1", "Item 2"));
dataAddition1.playFromStart();
PauseTransition dataAddition2 = new PauseTransition(Duration.seconds(6));
dataAddition2.setOnFinished(e -> data.setAll("Probematic"));
dataAddition2.playFromStart();
PauseTransition dataAddition3 = new PauseTransition(Duration.seconds(9));
dataAddition3.setOnFinished(e -> data.setAll("Item 3", "Item 4", "Item 5"));
dataAddition3.playFromStart();
tableView.setItems(data);
// Add data to independent list-view
listView.setItems(data);
stage.setScene(new Scene(vBox, 200, 300));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
=======================================
RuntimeException in ListView
=======================================
import javafx.animation.PauseTransition;
import javafx.application.Application;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Test extends Application {
@Override
public void start(Stage stage) throws Exception {
VBox vBox = new VBox(20);
// Create ListView
ListView<String> listView = new ListView<>();
listView.setCellFactory((ListView<String> param) -> {
return new ListCell<String>() {
@Override
protected void updateItem(String item, boolean empty) {
if (item != null) {
setGraphic(new Label(item));
if (item.equals("Probematic")) {
throw new RuntimeException("Unexpected RuntimeException");
}
} else {
setGraphic(null);
}
}
};
});
vBox.getChildren().add(listView);
// Create independent TableView
TableView<String> tableView = new TableView<String>();
TableColumn<String, String> tableColumn = new TableColumn<String, String>("Heading");
tableColumn.setCellValueFactory(v -> {
return new SimpleObjectProperty<String>(v.getValue());
});
tableView.getColumns().add(tableColumn);
vBox.getChildren().add(tableView);
// Add data to TableView
ObservableList<String> data = FXCollections.observableArrayList();
PauseTransition dataAddition1 = new PauseTransition(Duration.seconds(3));
dataAddition1.setOnFinished(e -> data.setAll("Item 1", "Item 2"));
dataAddition1.playFromStart();
PauseTransition dataAddition2 = new PauseTransition(Duration.seconds(6));
dataAddition2.setOnFinished(e -> data.setAll("Probematic"));
dataAddition2.playFromStart();
PauseTransition dataAddition3 = new PauseTransition(Duration.seconds(9));
dataAddition3.setOnFinished(e -> data.setAll("Item 3", "Item 4", "Item 5"));
dataAddition3.playFromStart();
tableView.setItems(data);
// Add data to independent list-view
listView.setItems(data);
stage.setScene(new Scene(vBox, 200, 300));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
=======================================
RuntimeException in TableView
=======================================
import javafx.animation.PauseTransition;
import javafx.application.Application;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Test extends Application {
@Override
public void start(Stage stage) throws Exception {
VBox vBox = new VBox(20);
// Create independent ListView
ListView<String> listView = new ListView<>();
vBox.getChildren().add(listView);
// Create TableView
TableView<String> tableView = new TableView<String>();
TableColumn<String, String> tableColumn = new TableColumn<String, String>("Heading");
tableColumn.setCellValueFactory(v -> {
return new SimpleObjectProperty<String>(v.getValue());
});
tableColumn.setCellFactory((TableColumn<String, String> param) -> {
return new TableCell<String, String>() {
@Override
protected void updateItem(String item, boolean empty) {
if (item != null) {
setGraphic(new Label(item));
if (item.equals("Probematic")) {
throw new RuntimeException("Unexpected RuntimeException");
}
} else {
setGraphic(null);
}
}
};
});
tableView.getColumns().add(tableColumn);
vBox.getChildren().add(tableView);
// Add data to TableView
ObservableList<String> data = FXCollections.observableArrayList();
PauseTransition dataAddition1 = new PauseTransition(Duration.seconds(3));
dataAddition1.setOnFinished(e -> data.setAll("Item 1", "Item 2"));
dataAddition1.playFromStart();
PauseTransition dataAddition2 = new PauseTransition(Duration.seconds(6));
dataAddition2.setOnFinished(e -> data.setAll("Probematic"));
dataAddition2.playFromStart();
PauseTransition dataAddition3 = new PauseTransition(Duration.seconds(9));
dataAddition3.setOnFinished(e -> data.setAll("Item 3", "Item 4", "Item 5"));
dataAddition3.playFromStart();
tableView.setItems(data);
// Add data to independent list-view
listView.setItems(data);
stage.setScene(new Scene(vBox, 200, 300));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
=======================================
RuntimeException in ListView
=======================================
import javafx.animation.PauseTransition;
import javafx.application.Application;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Test extends Application {
@Override
public void start(Stage stage) throws Exception {
VBox vBox = new VBox(20);
// Create ListView
ListView<String> listView = new ListView<>();
listView.setCellFactory((ListView<String> param) -> {
return new ListCell<String>() {
@Override
protected void updateItem(String item, boolean empty) {
if (item != null) {
setGraphic(new Label(item));
if (item.equals("Probematic")) {
throw new RuntimeException("Unexpected RuntimeException");
}
} else {
setGraphic(null);
}
}
};
});
vBox.getChildren().add(listView);
// Create independent TableView
TableView<String> tableView = new TableView<String>();
TableColumn<String, String> tableColumn = new TableColumn<String, String>("Heading");
tableColumn.setCellValueFactory(v -> {
return new SimpleObjectProperty<String>(v.getValue());
});
tableView.getColumns().add(tableColumn);
vBox.getChildren().add(tableView);
// Add data to TableView
ObservableList<String> data = FXCollections.observableArrayList();
PauseTransition dataAddition1 = new PauseTransition(Duration.seconds(3));
dataAddition1.setOnFinished(e -> data.setAll("Item 1", "Item 2"));
dataAddition1.playFromStart();
PauseTransition dataAddition2 = new PauseTransition(Duration.seconds(6));
dataAddition2.setOnFinished(e -> data.setAll("Probematic"));
dataAddition2.playFromStart();
PauseTransition dataAddition3 = new PauseTransition(Duration.seconds(9));
dataAddition3.setOnFinished(e -> data.setAll("Item 3", "Item 4", "Item 5"));
dataAddition3.playFromStart();
tableView.setItems(data);
// Add data to independent list-view
listView.setItems(data);
stage.setScene(new Scene(vBox, 200, 300));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
- relates to
-
JDK-8090078 [TableView] CellValueFactory robustness against RuntimeException, controls no longer render
- Open