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

ComboBox: incorrect behavior when clicking the arrow

    Details

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

      9-ea-104

      Description

      This happens if the editable property is dynamically set to true after the skin is created. The example below compares a combo which is editable from start with a combo that has its editable set via a button.

      Run and
      - open the popup of the initially editable combo
      - click on the arrow: popup is hidden - expected behavior
      - click on the button to make the other combo editable
      - open popup of other clickup and click on its arrow
      - expected: same as first combo, that is hide popup
      - actual: popup hidden and shown again

      Technical reason is ComboBoxBaseSkin: it registers the mouse handler only if the combo is editable at that time of skin instantiation. Aside: fixing this will make a complete hack around JDK-8150951 even more hacky ;-)

      public class ComboEditableArrowHandler extends Application {

          private Parent getContent() {
              ComboBox box = new ComboBox(FXCollections.observableArrayList("one", "two", "three"));
              box.setEditable(true);
              box.setValue("initial editable");
              ComboBox core = new ComboBox(FXCollections.observableArrayList("one", "two", "three"));
              core.setValue("dynamic editable");
              Button toggle = new Button("toggle editable");
              toggle.setOnAction(e -> {
                  core.setEditable(!core.isEditable());
              });
              
              return new VBox(10, box, core, toggle);
          }
          
          @Override
          public void start(Stage primaryStage) throws Exception {
              primaryStage.setScene(new Scene(getContent()));
              primaryStage.show();
          }

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


        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              fastegal Jeanette Winzenburg
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: