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

Size of choice box is changed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.0, fx2.0.2
    • Fix Version/s: fx2.1
    • Component/s: javafx
    • Labels:
    • Environment:

      java6
      windows 7
      fx 2.0.2 b04

      Description

      To reproduce run following code
      1 test case: choose some item in choice box, press "reset" button. Choice box become shoter.
      2 test case: try to add some long item "looooooooooo00000ong" . Choice box doesn't change the size.


      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.ChoiceBox;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class ChoiceBoxSa extends Application {
          ChoiceBox cb;

          protected Scene getScene() {
              cb = new ChoiceBox();

              HBox content = new HBox(5);
              content.getChildren().add(cb);
              reset();

              HBox addBox = new HBox();
              final TextField toAdd = new TextField();
              Button addBtn = new Button("Add");
              addBtn.setOnAction(new EventHandler<ActionEvent>() {

                  public void handle(ActionEvent t) {
                      cb.getItems().add(toAdd.getText());
                  }
              });


              HBox clearBox = new HBox();
              Button resetBtn = new Button("Reset");
              resetBtn.setOnAction(new EventHandler<ActionEvent>() {

                  public void handle(ActionEvent t) {
                      reset();
                  }
              });
              clearBox.getChildren().add(resetBtn);

              addBox.getChildren().add(toAdd);
              addBox.getChildren().add(addBtn);
              VBox controls = new VBox();
              controls.getChildren().add(clearBox);
              controls.getChildren().add(addBox);
              content.getChildren().add(controls);
              Scene res = new Scene(content);
              return res;
          }

          protected void reset() {
              cb.getItems().clear();
              cb.getItems().add("1234567890");
              cb.getItems().add(3);
              cb.getItems().add(false);
          }

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

          @Override
          public void start(Stage stage) throws Exception {
              stage.setScene(getScene());
              stage.show();
          }
      }

        Attachments

          Activity

            People

            Assignee:
            psomashe Parvathi Somashekar (Inactive)
            Reporter:
            anazarov Andrey Nazarov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: