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

ComboBox dropdown wrong location in RTL popup

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :
      openjdk version "1.8.0_111"
      OpenJDK Runtime Environment (build 1.8.0_111-8u111-b14-3-b14)
      OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux 4.8.0-1-amd64 #1 SMP Debian 4.8.7-1 (2016-11-13) x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      ComboBox inside a Popup or PopupControl displays its dropdown in the wrong location, if root of Popup has RTL orientation.

      Illustration available here: http://imgur.com/a/Lolq6

      This looks similar to JDK-8125934 , but it still occurs in 8u111, so it's either a new similar bug, or a regression.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See attached demo code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Drop down should appear below combobox.
      ACTUAL -
      Drop down appears far from the combobox, about (size of Popup) pixels to the left

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package sample;

      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.geometry.NodeOrientation;
      import javafx.geometry.Point2D;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ComboBox;
      import javafx.scene.control.Label;
      import javafx.scene.control.PopupControl;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.VBox;
      import javafx.stage.PopupWindow;
      import javafx.stage.Stage;


      public class Demo extends Application {
          @Override
          public void start(Stage stage) throws Exception {
              Button b = new Button("Click me");
              b.setOnAction(event -> {
                  PopupControl popup = new PopupControl();
                  popup.setAnchorLocation(PopupWindow.AnchorLocation.CONTENT_TOP_RIGHT);
                  popup.setAutoHide(true);
                  ComboBox<String> cb = new ComboBox<>(FXCollections.observableArrayList("foo", "bar"));
                  HBox box = new HBox(5, new Label("Select value"), cb);
                  box.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
                  // This is only to make the popup more visible. Removing it doesn't change the occurrence of the bug.
                  box.setStyle("-fx-background-color: derive(-fx-background, 30%); -fx-border-color: black; -fx-border-width: 1px;");
                  popup.getScene().setRoot(box);

                  Point2D anchor = b.localToScreen(b.getWidth(), b.getHeight());
                  popup.show(b, anchor.getX(), anchor.getY());
              });
              ComboBox<String> cb = new ComboBox<>(FXCollections.observableArrayList("foo", "bar"));
              VBox vb = new VBox(10, b, cb);
              vb.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
              Scene scene = new Scene(vb, 200, 200);
              stage.setScene(scene);

              stage.show();
          }


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

      }

      ---------- END SOURCE ----------

        Attachments

        1. Demo.java
          2 kB
        2. Utils.patch
          0.6 kB

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: