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

ChangeListener not calling for internal JavaFX ScrollBar in WebView

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P5 P5
    • None
    • jfx11, 8u191
    • javafx
    • web
    • x86_64
    • windows_7

      ADDITIONAL SYSTEM INFORMATION :
      Windows 64 bit machine
      Open JDK 11.0.2
      Open JFX 11.0.2


      A DESCRIPTION OF THE PROBLEM :
      I have added ChangeListener for JavaFX scrollbar valueProperty() variable. This listener is not calling in Open Java FX 11. The same code was works in Oracle JDK 8 which includes Java FX with it.

      Note: This "ScrollBar" is looked up from WebView.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Attached the sample program code, please run it. ChangeListener is not calling when we scroll the scrollbar in webview.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      ChangeListener should be called when we scroll webview scrollbar

      ---------- BEGIN SOURCE ----------
      package samplefxprogram;

      import java.util.Set;
      import javafx.application.Application;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.geometry.Orientation;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.stage.Stage;
      import javafx.scene.control.ScrollBar;
      import javafx.scene.web.WebView;
      import javafx.scene.layout.Pane;
      import javafx.scene.web.WebEngine;

      public class SampleFXProgram extends Application {
          @Override
          public void start(Stage primaryStage) {
              int alert_width = 939;
              int alert_height = 582;

              WebView view = new WebView();
              view.setContextMenuEnabled(false);
              view.getEngine().setJavaScriptEnabled(true);

              WebEngine webEngine = view.getEngine();
              webEngine.load("https://openjfx.io/");

              view.setMaxSize(939 + 2, alert_height);
              view.setMinSize(alert_width + 2, alert_height);
              view.setPrefSize(alert_width + 2, alert_height);

              ScrollBar viewsb = null;
              Set<Node> viewNodes = view.lookupAll(".scroll-bar");
              for (final Node node : viewNodes) {
                  if (node instanceof ScrollBar) {
                      viewsb = (ScrollBar) node;
                      if (viewsb.getOrientation() == Orientation.VERTICAL) {
                          break;
                      }
                  }
              }

              Pane root = new Pane();
              root.getChildren().addAll(view);

              Scene scene = new Scene(root);
              primaryStage.setScene(scene);
              primaryStage.setTitle("ScrollBar Example");

              viewsb.valueProperty().addListener(new ChangeListener<Number>() {

                  @Override
                  public void changed(ObservableValue<? extends Number> observable,
                          Number oldValue, Number newValue) {
                      System.out.println("Webview Scrollbar Listener calling");
                  }
              });

              primaryStage.show();
          }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Not found any work around.

      FREQUENCY : always


            kcr Kevin Rushforth
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: