• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transparent background in javafx StackPane

 
Yuliy Khlyebnikov
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody, I am trying to make my StackPane completely transparent with non transparent content. I have already tried to set a background color with rgb(255,255,255,0) to that pane, but it still having a white background and I can not find out why? I am using embed javafx to swing so I am setting a transparent scene to a JFXPanel like that:

the result:
img
If enybody knows how to solve this issue, can give me a hand with it? Thanks in advance)))
 
John Damien Smith
Ranch Hand
Posts: 321
19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really need to use embedded Swing?
If you can write a pure JavaFX application then you can achieve the desired effect, transparent panes with non-transparent children with no issue.
See:
http://stackoverflow.com/questions/12717487/how-to-implement-a-transparent-pane-with-non-transparent-children

You may wish to supply a complete example (sscce), that replicates the issue.
See:
http://sscce.org

You don't need to set the background or opaque properties of the JFXPanel, because, regardless JFXPanel isOpaque will always return false, so these two settings will be ignored.
See:
https://docs.oracle.com/javase/8/javafx/api/javafx/embed/swing/JFXPanel.html#isOpaque--

I did some quick testing and drawing a JFXPanel over a Swing panel which has an opaque background works fine. Drawing it over a Swing panel which has a translucent background seems to double the underlying background color in the JFXPanel background (as you have in your image). I don't really have a solution to this. It may be a bug in the JFXPanel implementation, which you could log at http://bugreport.java.com.

Here is the test program I used:

 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!