Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8117404

ComboBox does not apply style to dropdown portion first time it opens

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8
    • javafx
    • JavaFX 8b113, Windows 7 64-bit (32-bit java)

      Run the following test code. Notice that when you click on the combobox the first time it has standard white background. The second time it has the colors specified in the CSS.

      I hope this can be fixed still, it is the first time I needed a ComboBox and it is kinda surprising this doesn't work properly.

      .root {
        -c-base: rgb(173, 216, 230);
        -c-bg-transparent: rgba(0, 0, 0, 0.66);
      }

      .combo-box .text-input {
        -fx-text-fill: -c-base;
      }

      .combo-box .list-cell {
        -fx-background-color: -c-bg-transparent;
        -fx-text-fill: -c-base;
      }

      .combo-box-popup {
        -fx-background-color: -c-bg-transparent;
        -fx-text-fill: -c-base;
      }

      package hs.mediasystem;

      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.scene.Scene;
      import javafx.scene.control.ComboBox;
      import javafx.stage.Stage;

      public class ComboBoxCSSTest extends Application {

        public static void main(String[] args) {
          Application.launch(args);
        }

        @Override
        public void start(Stage primaryStage) throws Exception {
          Scene scene = new Scene(new ComboBox<>(FXCollections.observableArrayList("Aap", "Noot", "Mies")));

          scene.getStylesheets().add("combobox.css");

          primaryStage.setScene(scene);

          primaryStage.setWidth(400);
          primaryStage.setHeight(300);
          primaryStage.show();
        }
      }

      css file:


      .root {
        -c-base: rgb(173, 216, 230);
        -c-bg-transparent: rgba(0, 0, 0, 0.66);
      }

      .combo-box .text-input {
        -fx-text-fill: -c-base;
      }

      .combo-box .list-cell {
        -fx-background-color: -c-bg-transparent;
        -fx-text-fill: -c-base;
      }

      .combo-box-popup {
        -fx-background-color: -c-bg-transparent;
        -fx-text-fill: -c-base;
      }

            jgiles Jonathan Giles
            jhendrikx John Hendrikx
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: