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

Combobox list cell css styling it is not applied until we click on one of the items

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P2
    • 8u20
    • 8
    • javafx
    • Windows 7 64 bits
      JDK 8 b117 64 bits

    Description

      In the following example app:

      {code:CSSTest.java}
      public class CSSTest extends Application {

      /**
      * @param args
      */
      public static void main(String[] args) {
      launch(args);
      }

      /*
      * (non-Javadoc)
      * @see javafx.application.Application#start(javafx.stage.Stage)
      */
      @Override
      public void start(Stage primaryStage) throws Exception {
      ComboBox<String> combo = new ComboBox<>();
      combo.getItems().addAll("Item 1", "Item 2", "Item 3", "Item 4");
      combo.getSelectionModel().selectFirst();
      Group root = new Group();
      root.getChildren().add(combo);
      Scene scn = new Scene(root, 800, 600);
      scn.getStylesheets().add(CSSTest.class.getResource("default.css").toExternalForm());
      primaryStage.setScene(scn);
      primaryStage.show();
      }
      }
      {code}



      With the following css:
      {code}
      .list-cell:filled:selected:focused, .list-cell:filled:selected {
          /* 3:, 4: */
          -fx-background-color: linear-gradient(#333 0%, #777 25%, #aaa 75%, #eee 100%);
          -fx-text-fill: white; /* 5 */
      }
      .list-cell { -fx-text-fill: black; /* 5 */ }
      .list-cell:odd { -fx-background-color: white; /* 1 */ }
      .list-cell:even { -fx-background-color: #8f8; /* for information */ }
      .list-cell:filled:hover {
          -fx-background-color: #00f; /* 2 */
          -fx-text-fill: white; /* 5 */
      }
      {code}

      The first time I open the combo box under JDK 8 b117, the combo box it is not styled at all. Once I select an item by clicking on it, the styling appears and stays.

      The behaviour I expect is the one that JDK 7 has. The combobox should be styled.


      As additional information I have tried too to do a scn.getStylesheets().clear(); before I add my custom stylesheet but the problem persists.

      Attachments

        Issue Links

          Activity

            People

              dgrieve David Grieve
              pgomezjfx Pablo Gómez (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: