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

Opacity is ignored for scene contained in a JFXPanel (Since b94)

    Details

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

      Win7 64 bit SP1, GeForce GTX680 (drivers version: 320.18)

      Description

      A scene contained in a JFXPanel is always opaque. This issue has been introduced in b94. Note that if the JWindow's content is set with swing components, transparency is set correctly. When using FX stage with transparency style, the transparency is also set correctly. So the issue seems related to using the JFXPanel.

      To reproduce, run the following code. The expected result is a fully transparent window/scene with the text visible (b93). The actual result is a fully opaque scene (b94, b96).

      import java.awt.Color;

      import javafx.application.Platform;
      import javafx.embed.swing.JFXPanel;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;

      import javax.swing.JWindow;
      import javax.swing.SwingUtilities;

      public class TestTransparencyFXPanel {
      private static JFXPanel fxPanel;

      public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {

      @Override
      public void run() {
      JWindow window = new JWindow();
      window.setBackground(new Color(255, 255, 255, 0));
      window.getContentPane().setBackground(new Color(255, 255, 255, 0));

      fxPanel = new JFXPanel();
      fxPanel.setBackground(new Color(255, 255, 255, 0));
      window.add(fxPanel);

      window.setSize(400, 400);
      window.setLocationRelativeTo(null);

      Platform.runLater(new Runnable() {

      @Override
      public void run() {
      initFX();
      }
      });

      window.setVisible(true);
      }
      });
      }

      private static void initFX() {
      Label label = new Label("TEST");
      label.setBackground(null);
      Scene scene = new Scene(label);
      scene.setFill(javafx.scene.paint.Color.TRANSPARENT);
      fxPanel.setScene(scene);
      }

      }

        Attachments

          Activity

            People

            • Assignee:
              ant Anton Tarasov
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: