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

CSS errors printed if a ComboBox's items are removed after a Stage is hidden

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: emb-8u6, 8u20
    • Component/s: javafx
    • Labels:
    • Environment:

      Linux Java 1.8.0ea b117

      Description

      If you remove the items from a combobox after it's stage has been hidden it will print errors to the console like this:

      Dec 10, 2013 10:50:16 AM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-text-base-color' while resolving lookups for '-fx-text-fill' from rule '*.combo-box>*.list-cell' in stylesheet jar:file:/usr/local/jdk1.8.0/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss

      If you remove the combo from the scene before clearing its items then the errors don't appear.

      Run the provided test class and use the button to open a new stage with a combobox. Then close the new stage and observe the errors printed to the console.

      ************************************* Test Class **************************************
      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ComboBox;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;
      import javafx.stage.WindowEvent;

      public class ComboBoxTest extends Application {

         public void start(final Stage primaryStage) throws Exception {

            primaryStage.centerOnScreen();
            primaryStage.setHeight(350);
            primaryStage.setWidth(500);

            Button showButton = new Button("New Stage...");
            showButton.setOnAction(new EventHandler<ActionEvent>() {
               public void handle(ActionEvent event) {
                  Stage newStage = createNewView();
                  newStage.show();
               }
            });

            primaryStage.setScene(new Scene(new StackPane(showButton)));
            primaryStage.show();

         }

         private Stage createNewView() {
            final Stage stage = new Stage();

            final ComboBox<String> combo = new ComboBox<>();
            combo.getItems().addAll("One", "Two", "Three");
            combo.setValue(combo.getItems().get(0));
            final StackPane pane = new StackPane(combo);
            stage.setScene(new Scene(pane, 300, 150));
            
            stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
               public void handle(WindowEvent event) {
                  event.consume();
                  Platform.runLater(new Runnable() {
                     public void run() {
                        stage.hide();
                        // uncomment this line and the errors go away.
                        // pane.getChildren().clear();
                        combo.getItems().clear();
                     }
                  });
               }
            });

            return stage;
         }

         public static void main(String[] args) throws Exception {
            launch(args);
         }

      }

        Attachments

          Activity

            People

            Assignee:
            dgrieve David Grieve
            Reporter:
            csmithjfx Charles Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: