Running the snippet below renders the text in the label set as the graphic in white instead of black
package org.eclipse.fx.code.compensator.project.vcs.git;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class TestMe extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane p = createComboSample();
Button b = new Button("Open Dialog");
p.setBottom(b);
Scene s = new Scene(p, 300, 300);
primaryStage.setScene(s);
primaryStage.show();
}
private static BorderPane createComboSample() {
BorderPane p = new BorderPane();
ComboBox<String> box = new ComboBox<>(FXCollections.observableArrayList("A","B","C"));
box.setButtonCell(new ListCell<String>() {
@Override
protected void updateItem(String item, boolean empty) {
if( item != null && ! empty ) {
setGraphic(new Label(item));
} else {
setGraphic(null);
}
super.updateItem(item, empty);
}
});
box.getSelectionModel().select(0);
p.setCenter(box);
return p;
}
public static void main(String[] args) {
launch(args);
}
}
I've tested this in u5 and u20 and there there the behavior is also wrong. I have not yet found out who the label is rendered in white. The only work around in found was to add the following css rule to my stylesheet.
.combo-box > .list-cell > .label {
-fx-text-fill: -fx-text-base-color;
}
package org.eclipse.fx.code.compensator.project.vcs.git;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class TestMe extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane p = createComboSample();
Button b = new Button("Open Dialog");
p.setBottom(b);
Scene s = new Scene(p, 300, 300);
primaryStage.setScene(s);
primaryStage.show();
}
private static BorderPane createComboSample() {
BorderPane p = new BorderPane();
ComboBox<String> box = new ComboBox<>(FXCollections.observableArrayList("A","B","C"));
box.setButtonCell(new ListCell<String>() {
@Override
protected void updateItem(String item, boolean empty) {
if( item != null && ! empty ) {
setGraphic(new Label(item));
} else {
setGraphic(null);
}
super.updateItem(item, empty);
}
});
box.getSelectionModel().select(0);
p.setCenter(box);
return p;
}
public static void main(String[] args) {
launch(args);
}
}
I've tested this in u5 and u20 and there there the behavior is also wrong. I have not yet found out who the label is rendered in white. The only work around in found was to add the following css rule to my stylesheet.
.combo-box > .list-cell > .label {
-fx-text-fill: -fx-text-base-color;
}