如何在JavaFX中向窗口添加阴影?

编程入门 行业动态 更新时间:2024-10-21 03:50:37
本文介绍了如何在JavaFX中向窗口添加阴影?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我删除了主要阶段的默认边框:

I have removed the default borders around the primary stage:

stage.initStyle(StageStyle.UNDECORATED)

这删除了我想要的窗口边框,但现在我想在窗口下面有一个阴影。

This removes the window borders which is what I want, but now I'd like to have a drop shadow under the window.

顶级 BorderPane 对象有一个 dropshadow 应用效果,但阴影被切断:

The top level BorderPane object has a dropshadow effect applied, but the shadow is cut off:

你可以在右下角看到阴影,但是一旦主应用区域结束,阴影就会被切断。

You can see the shadow slightly on the bottom right, but as soon as the main application area ends the shadow is cut off.

推荐答案

我创建了一个前面的例子。使用在以后版本中链接的特定修订版本,我从对话框中删除了阴影效果。

I created an example for this earlier. Use the specific revision linked as in later revisions I dropped the shadow effect from the dialog.

示例将舞台内容放在包含两个窗格的StackPane中。阴影仅应用于背景窗格,对话框内容放置在顶部窗格中。顶部窗格的背景略微嵌入底部窗格,以便背景和阴影可以显示。

The sample places the stage content in a StackPane containing two panes. The shadow is only applied to the background Pane and the dialog content is placed in a top pane. The background of the top pane is slightly inset from the bottom pane so that the background and shadow can show through.

进一步的讨论是在显示未修饰/透明舞台周围的阴影。

Further discussion is in a thread on displaying a shadow around an undecorated/transparent stage.

更多推荐

如何在JavaFX中向窗口添加阴影?

本文发布于:2023-11-12 03:55:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580447.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阴影   中向   窗口   如何在   JavaFX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!