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

[SWT] Provide public API to access FXCanvas for embedded scene

XMLWordPrintable

    • generic
    • other

      A DESCRIPTION OF THE REQUEST :
      Up to now, there is no way to access the enclosing FXCanvas for a given (embedded) Scene. Please provide some public API via which the enclosing FXCanvas of an embedded Scene can be obtained. That could well be a static method within FXCanvas.

      JUSTIFICATION :
      In the context of the JavaFX-SWT-integration there are use cases where the enclosing of FXCanvas of the embedded scene needs to be obtained. Up to now this is only possible using reflection.


      CUSTOMER SUBMITTED WORKAROUND :
      Up to now, we can only access the enclosing FXCanvas via the scene window using the following code (based on reflection):

      protected FXCanvas getFXCanvas(Window window) {
        if (window != null) {
          // Obtain FXCanvas by accessing outer class
          // of FXCanvas$HostContainer
          FXCanvas canvas = ReflectionUtils.getPrivateFieldValue(ReflectionUtils. <Object> getPrivateFieldValue(window,"host"), "this$0");
          return canvas;
        }
        return null;
      }


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

              Created:
              Updated:
              Resolved: