Is there any way to make a Stage transparent without using StageStyle.TRANSPARENT? I want the stage to be transparent, but using stage.initStyle(StageStyle.TRANSPARENT)
causes other kinds of side-effects that I do not want; one of which, for example, is removing the border, but there are others.
Asked
Active
Viewed 54 times
1

vbyzjnlehi
- 307
- 2
- 15
-
1hmm .. don't understand - what _exactly_ do you want to be transparent? A transparent window is .. well, transparent everywhere, including its decorations (border, title area). Just having the space filled by the scene transparent is not possible, afaik (but might be wrong) – kleopatra Aug 15 '21 at 09:54
-
Imagine that you have a normal window with the titlebar and everything, but in the middle of the window you had a rectangle where you could see through it. The only way I can think of is to make StageStyle.TRANSPARENT, but then you would have to re-implement all the native window styling and behaviors. – vbyzjnlehi Aug 15 '21 at 19:12
-
1You are correct: "you would have to re-implement all the native window styling and behaviors." By using `StageStyle.TRANSPARENT`, you have basically told Windows that **you** will handle all of the Window decorations with your JavaFX code. – Zephyr Aug 16 '21 at 04:50
-
@Zephyr Right, so my question is whether there is a way to do transparency without using `StageStyle.TRANSPARENT`, because I don't want to tell Windows that I will handle all the decorations. – vbyzjnlehi Aug 16 '21 at 12:31
-
You could use something like the [`copyBackground()`](https://stackoverflow.com/questions/22663681/javafx-effect-on-background) method in this answer, though that is a pure hack and I'm guessing that approach will have issues if you try to accomplish it in a relatively robust manner, so I don't necessarily recommend it. – jewelsea Aug 16 '21 at 21:09