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

Combobox is rendered outside of container

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: javafx
    • Environment:

      jdk1.8.0b96

      Description

      To reproduce:
      1. Push 'Add item'
      2. Open and close combobox
      3. Push 'Set placeholder'
      4. Push 'Remove all'
      5. Open combobox

      Result: it will be rendered outside of the parent pane

      import com.sun.javafx.runtime.VersionInfo;
      import javafx.application.Application;
      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.control.Label;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.VBox;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Circle;
      import javafx.stage.Stage;

      public class ComboBoxAppWithPlaceholder extends Application {
          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage stage) throws Exception {
              stage.setTitle(VersionInfo.getRuntimeVersion());
              stage.setScene(createScene());

              stage.show();
          }

          private Scene createScene() {
              final ComboBox comboBox = new ComboBox();

              Button addItem = new Button("Add item");
              addItem.setOnAction(new EventHandler<ActionEvent>() {
                  int i;
                  @Override
                  public void handle(ActionEvent actionEvent) {
                      comboBox.getItems().add("Item " + i++);
                  }
              });

              Button remove = new Button("Remove all");
              remove.setOnAction(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent actionEvent) {
                      comboBox.getItems().clear();
                  }
              });

              Button setPlaceHolder = new Button("Set placeholder");
              setPlaceHolder.setOnAction(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent actionEvent) {
                      comboBox.setPlaceholder(new Circle(12, Color.RED));
                  }
              });

              HBox root = new HBox();

              Pane pane = new Pane();
              pane.setPrefSize(220, 220);
              pane.setMinSize(220, 220);
              pane.setStyle("-fx-border-color: PALEGREEN");
              pane.getChildren().add(comboBox);

              root.getChildren().add(new VBox(pane, addItem, remove, setPlaceHolder));
              root.getChildren().add(new VBox(new Label("Stub")));

              return new Scene(root, 400, 300);
          }
      }

        Attachments

          Activity

            People

            Assignee:
            jgiles Jonathan Giles
            Reporter:
            dzinkevi Dmitry Zinkevich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: