Created from the comment in RT-32229:
The following behaves differently:
.root {
-fx-background: #f8f8f8;
-fx-selection-bar: linear-gradient(to top, derive(-fx-background, -2%) 0%, derive(-fx-background, 50%) 100%);
}
throws an error/warning (IllegalArgumentException) in JavaFX 8.
while the following does not:
.root {
-fx-selection-bar: linear-gradient(to top, derive(#f8f8f8, -2%) 0%, derive(#f8f8f8, 50%) 100%);
}
They should behave the same, though.
In JavaFX 2.2 the first results in a light blue, while the second one results in a gray selection color.
Here's a sample code (select the table row or the menu):
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 TestApp5 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("/style.css");
stage.setScene(scene);
stage.show();
}
}
The following behaves differently:
.root {
-fx-background: #f8f8f8;
-fx-selection-bar: linear-gradient(to top, derive(-fx-background, -2%) 0%, derive(-fx-background, 50%) 100%);
}
throws an error/warning (IllegalArgumentException) in JavaFX 8.
while the following does not:
.root {
-fx-selection-bar: linear-gradient(to top, derive(#f8f8f8, -2%) 0%, derive(#f8f8f8, 50%) 100%);
}
They should behave the same, though.
In JavaFX 2.2 the first results in a light blue, while the second one results in a gray selection color.
Here's a sample code (select the table row or the menu):
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 TestApp5 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("/style.css");
stage.setScene(scene);
stage.show();
}
}
- duplicates
-
JDK-8097421 com.sun.javafx.css.StyleHelper calculateValue Could not resolve....
- Closed
- relates to
-
JDK-8291853 [CSS] ClassCastException in CssStyleHelper calculateValue
- Resolved