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);
}
}
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);
}
}