Since I first tested JavaFX 8 (b83) I can't really use my application, due to a StackOverflowError, which is caused by CSS. Now I tested with b101 and it still exists.
Appearently it only occurs with Modena style.
Here's how you can reproduce it (use the menu or select the table row):
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.Callback;
public class TestApp extends Application {
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage stage) throws Exception {
MenuBar menuBar = new MenuBar();
Menu menu = new Menu("Menu");
menu.getItems().add(new MenuItem("test"));
menuBar.getMenus().add(menu);
TableView<String> tableView = new TableView<String>();
tableView.setItems(FXCollections.observableArrayList("String"));
TableColumn<String, String> tableColumn = new TableColumn<String, String>();
tableColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<String, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<String, String> stringStringCellDataFeatures) {
return new SimpleStringProperty(stringStringCellDataFeatures.getValue());
}
});
tableView.getColumns().add(tableColumn);
VBox vBox = new VBox();
vBox.getChildren().add(menuBar);
vBox.getChildren().add(tableView);
Scene scene = new Scene(vBox);
scene.getStylesheets().add("/styles.css");
stage.setScene(scene);
stage.show();
}
}
styles.css:
.root {
-fx-selection-bar: linear-gradient(to bottom, derive(-fx-background, -7%) 0%, derive(-fx-background, -34%) 100%);
}
The error is:
java.lang.StackOverflowError
at com.sun.javafx.css.SimpleSelector.applies(SimpleSelector.java:236)
at com.sun.javafx.css.CompoundSelector.stateMatches(CompoundSelector.java:233)
at com.sun.javafx.css.CompoundSelector.stateMatches(CompoundSelector.java:206)
at javafx.scene.CssStyleHelper.getStyle(CssStyleHelper.java:702)
at javafx.scene.CssStyleHelper.resolveRef(CssStyleHelper.java:951)
at javafx.scene.CssStyleHelper.resolveLookups(CssStyleHelper.java:1022)
I believe the error is, that it can't resolve -fx-background.
Appearently it only occurs with Modena style.
Here's how you can reproduce it (use the menu or select the table row):
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.Callback;
public class TestApp extends Application {
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage stage) throws Exception {
MenuBar menuBar = new MenuBar();
Menu menu = new Menu("Menu");
menu.getItems().add(new MenuItem("test"));
menuBar.getMenus().add(menu);
TableView<String> tableView = new TableView<String>();
tableView.setItems(FXCollections.observableArrayList("String"));
TableColumn<String, String> tableColumn = new TableColumn<String, String>();
tableColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<String, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<String, String> stringStringCellDataFeatures) {
return new SimpleStringProperty(stringStringCellDataFeatures.getValue());
}
});
tableView.getColumns().add(tableColumn);
VBox vBox = new VBox();
vBox.getChildren().add(menuBar);
vBox.getChildren().add(tableView);
Scene scene = new Scene(vBox);
scene.getStylesheets().add("/styles.css");
stage.setScene(scene);
stage.show();
}
}
styles.css:
.root {
-fx-selection-bar: linear-gradient(to bottom, derive(-fx-background, -7%) 0%, derive(-fx-background, -34%) 100%);
}
The error is:
java.lang.StackOverflowError
at com.sun.javafx.css.SimpleSelector.applies(SimpleSelector.java:236)
at com.sun.javafx.css.CompoundSelector.stateMatches(CompoundSelector.java:233)
at com.sun.javafx.css.CompoundSelector.stateMatches(CompoundSelector.java:206)
at javafx.scene.CssStyleHelper.getStyle(CssStyleHelper.java:702)
at javafx.scene.CssStyleHelper.resolveRef(CssStyleHelper.java:951)
at javafx.scene.CssStyleHelper.resolveLookups(CssStyleHelper.java:1022)
I believe the error is, that it can't resolve -fx-background.