12

I am just starting my second JavaFX projects, and I need to know when a Stage is being maximized. In Swing, this is fairly simple and can be accomplished by using a WindowListener/Event. However, after searching through JavaFX's Javadoc, I can't seem to find any way of listening to the state of a Stage.

Is there any way to do this?

4

1 回答 1

22

要了解是否Stage已最小化,您可以收听iconified属性:

stage.iconifiedProperty().addListener(new ChangeListener<Boolean>() {

    @Override
    public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
        System.out.println("minimized:" + t1.booleanValue());
    }
});

maximized在即将发布的 8.0 版本中添加了Correspondent属性:

stage.maximizedProperty().addListener(new ChangeListener<Boolean>() {

    @Override
    public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
        System.out.println("maximized:" + t1.booleanValue());
    }
});

您可以在此处下载 JDK 8(包括 FX8)的早期访问版本:http ://www.oracle.com/technetwork/java/javase/downloads/ea-jsp-142245.html

于 2013-03-28T12:05:22.913 回答