JavaFx中经过装饰且不可移动的阶段 [英] Decorated and not-movable stage in JavaFx

查看:61
本文介绍了JavaFx中经过装饰且不可移动的阶段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在JavaFx中创建一个装饰的舞台,它也将不可移动.我正在从另一个控制器类创建此阶段.我可以创建并显示舞台,但是舞台可以自由移动.我该如何创建呢?非常感谢您的帮助和建议.我正在粘贴打开新舞台的方法.

I want to create a decorated stage in JavaFx and it will be not movable too. I am creating this stage from another controller class. I am able to create and show the stage but it is moving freely. How can I create this? Help and suggestions are highly appreciated. I am pasting the method for opening new stage.

private void addReceiver() {

    Parent receivercvDetailsparent;

    try {
        receivercvDetailsparent = FXMLLoader.load(getClass().getClassLoader().getResource("com/project/fxml/ReceiverDetails.fxml"));
        Stage stageReceiver = new Stage();
        stageReceiver.initModality(Modality.APPLICATION_MODAL);
        stageReceiver.setTitle("AppName v2.0.0");
        stageReceiver.setScene(new Scene(receivercvDetailsparent));
        stageReceiver.initStyle(StageStyle.DECORATED);
        stageReceiver.setResizable(false);
        stageReceiver.getIcons().add(new Image("/com/project/images/logo.png"));
        stageReceiver.show();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

推荐答案

舞台通常是一个窗口,所以假装不可移动的唯一方法是使其没有装饰

A stage is a window usually so the only way to sort of fake it's immovability is to make it undecorated

stage.initStyle(StageStyle.UNDECORATED);

它只能防止窗口自动拖动,但恐怕这是您唯一可以做的事情

It only prevents window dragging automatically, but I'm afraid it is the only thing you can do

这篇关于JavaFx中经过装饰且不可移动的阶段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆