[英]How to set a window always on top of another specific window in javafx
I have a toolbox that needs to stay always on top of the main window, but not of any other windows. 我有一个工具箱,需要始终保持在主窗口的顶部,而不是其他任何窗口。 So what I would need is a .setAlwaysOnTop(true) but for a specific window.
因此,我需要一个.setAlwaysOnTop(true),但需要特定的窗口。 How do I do that?
我怎么做?
When you create the second Stage you have to call initOwner
and initModality
with Modality.WINDOW_MODAL
. 创建第二个阶段时,必须使用
Modality.WINDOW_MODAL
调用initOwner
和initModality
。 Then the new stage is always on top of the other but you can't interact with the parent stage. 然后,新阶段始终位于另一个阶段之上,但是您不能与父阶段进行交互。
For example: 例如:
public void createNewStage(Window parent) {
//... all the other stuff
Stage onTop = new Stage();
onTop.initOwner(parent);
onTop.initModality(Modality.WINDOW_MODAL);
onTop.show();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.