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

JavaFx MenuItems embedded in JApplet always open in their original location rather than under actual mouse location

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • 9
    • 8u25, 9
    • javafx
    • None

      1. Compile and embed the attached sample applet containing an embedded JavaFx Menu in an HTML file

      2. Open a browser (Firefox was used to demonstrate this issue) and maximize it. Navigate to the HTML file containing the embedded applet.

      3. Double click on the browser title bar to reduce it's size

      4. Click on the Menu in the menu bar. Observe that the drop down will appear completely outside the bounds of the browser window in a location that would have been valid for the maximized window


      ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

      public class FxApplet extends JApplet
      {
        protected Scene scene;
        protected Group root;

        @Override
        public final void init() { // This method is invoked when applet is loaded
          SwingUtilities.invokeLater(new Runnable()
          {
            @Override
            public void run()
            {
              initSwing();
            }
          });
        }

        private void initSwing() { // This method is invoked on Swing thread
          final JFXPanel fxPanel = new JFXPanel();
          add(fxPanel);

          Platform.runLater(new Runnable()
          {
            @Override
            public void run()
            {
              initFX(fxPanel);
              initApplet();
            }
          });
        }

        private void initFX(JFXPanel fxPanel) { // This method is invoked on JavaFX thread
          root = new Group();
          scene = new Scene(root);
          fxPanel.setScene(scene);
        }

        public void initApplet() {

          MenuBar menuBar = new MenuBar();

          Menu menuFile = new Menu("Menu");

          menuFile.getItems().addAll(new MenuItem("item 1"),
                                     new MenuItem("item 2"),
                                     new MenuItem("item 3"),
                                     new MenuItem("item 4"));

          menuBar.getMenus().addAll(menuFile);
          root.getChildren().addAll(menuBar);
        }

      }

            azvegint Alexander Zvegintsev
            dkamaljfx Danesh Kamal (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: