本文整理了Java中javafx.scene.Scene.windowProperty()
方法的一些代码示例,展示了Scene.windowProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scene.windowProperty()
方法的具体详情如下:
包路径:javafx.scene.Scene
类名称:Scene
方法名:windowProperty
暂无
代码示例来源:origin: speedment/speedment
Window window = newVal.windowProperty().get();
if( window != null ){
window.setOnCloseRequest( (ev) -> closeWindow() );
} else {
newVal.windowProperty().addListener( (ob, oldW, newW) -> {
newW.setOnCloseRequest( (ev) -> closeWindow() );
});
代码示例来源:origin: stackoverflow.com
@Override
public void postInit(Scene scene) {
...
scene.windowProperty().addListener(new InvalidationListener() {
@Override
public void invalidated(Observable observable) {
scene.getWindow().setOnCloseRequest(e -> {
e.consume();
action("exit").handle(new ActionEvent());
});
scene.windowProperty().removeListener(this);
}
});
}
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls
/**
* Get the window property of a node
*
* @param n
* the node the window property to observe
* @return the property
*/
public static ObservableValue<Window> windowProperty(Node n) {
ObjectProperty<Window> w = new SimpleObjectProperty<Window>();
ChangeListener<Window> l = (o, oldV, newV) -> w.set(newV);
n.sceneProperty().addListener((o, oldV, newV) -> {
if (oldV != null) {
oldV.windowProperty().removeListener(l);
}
if (newV != null) {
newV.windowProperty().addListener(l);
}
});
return w;
}
代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls
/**
* Get the window property of a node
*
* @param n
* the node the window property to observe
* @return the property
*/
public static ObservableValue<Window> windowProperty(Node n) {
ObjectProperty<Window> w = new SimpleObjectProperty<Window>();
ChangeListener<Window> l = (o, oldV, newV) -> w.set(newV);
n.sceneProperty().addListener((o, oldV, newV) -> {
if (oldV != null) {
oldV.windowProperty().removeListener(l);
}
if (newV != null) {
newV.windowProperty().addListener(l);
}
});
return w;
}
代码示例来源:origin: com.guigarage/ui-basics
public static void bindToStageTitle(Node n, StringProperty property) {
ChangeListener<Window> windowListener = (observable, oldValue, newValue) -> {
if (oldValue != null && oldValue instanceof Stage) {
((Stage) oldValue).titleProperty().unbindBidirectional(property);
}
if (newValue != null && newValue instanceof Stage) {
((Stage) newValue).titleProperty().bindBidirectional(property);
}
};
n.sceneProperty().addListener((observable, oldValue, newValue) -> {
if (oldValue != null) {
oldValue.windowProperty().removeListener(windowListener);
}
if (newValue != null) {
newValue.windowProperty().addListener(windowListener);
if (newValue.getWindow() != null && newValue.getWindow() instanceof Stage) {
((Stage) newValue.getWindow()).titleProperty().bindBidirectional(property);
}
}
});
if (n.getScene() != null) {
n.getScene().windowProperty().addListener(windowListener);
}
}
代码示例来源:origin: com.guigarage/ui-basics
public static void registerListenerForWindowFocus(Node n, InvalidationListener l) {
ChangeListener<Window> windowListener = (observable, oldValue, newValue) -> {
if (oldValue != null) {
oldValue.focusedProperty().removeListener(l);
}
if (newValue != null) {
newValue.focusedProperty().addListener(l);
}
};
n.sceneProperty().addListener((observable, oldValue, newValue) -> {
if (oldValue != null) {
oldValue.windowProperty().removeListener(windowListener);
}
if (newValue != null) {
newValue.windowProperty().addListener(windowListener);
if (newValue.getWindow() != null) {
newValue.getWindow().focusedProperty().addListener(l);
l.invalidated(newValue.getWindow().focusedProperty());
}
}
});
if (n.getScene() != null) {
n.getScene().windowProperty().addListener(windowListener);
}
}
代码示例来源:origin: com.guigarage/ui-basics
public static void registerListenerForStageFullscreen(Node n, InvalidationListener l) {
ChangeListener<Window> windowListener = (observable, oldValue, newValue) -> {
if (oldValue != null && oldValue instanceof Stage) {
((Stage) oldValue).fullScreenProperty().removeListener(l);
}
if (newValue != null && newValue instanceof Stage) {
((Stage) newValue).fullScreenProperty().addListener(l);
}
};
n.sceneProperty().addListener((observable, oldValue, newValue) -> {
if (oldValue != null) {
oldValue.windowProperty().removeListener(windowListener);
}
if (newValue != null) {
newValue.windowProperty().addListener(windowListener);
if (newValue.getWindow() != null && newValue.getWindow() instanceof Stage) {
((Stage) newValue.getWindow()).fullScreenProperty().addListener(l);
l.invalidated(((Stage) newValue.getWindow()).fullScreenProperty());
}
}
});
if (n.getScene() != null) {
n.getScene().windowProperty().addListener(windowListener);
}
}
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls
@SuppressWarnings("null")
@Override
protected Node createWindowArea() {
BorderPane root = new BorderPane();
getStyleClass().addAll("default-window", "decorated-root"); //$NON-NLS-1$ //$NON-NLS-2$
Node dialogTitleBar = createTitleBar();
this.dialogAreaNode = (TitleAreaNode) dialogTitleBar;
registerTitleBar(dialogTitleBar);
this.titleProperty = ((TitleAreaNode) dialogTitleBar).titleProperty();
root.setTop(dialogTitleBar);
dialogTitleBar.applyCss();
sceneProperty().addListener((o) -> {
Scene s = getScene();
if (s != null) {
if (s.getWindow() != null) {
handleStageAttached();
} else {
s.windowProperty().addListener((o2) -> {
if (s.getWindow() != null) {
handleStageAttached();
}
});
}
}
});
this.trimPane = new BorderPane();
root.setCenter(this.trimPane);
this.contentProperty = this.trimPane.centerProperty();
return root;
}
代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls
@SuppressWarnings("null")
@Override
protected Node createWindowArea() {
BorderPane root = new BorderPane();
getStyleClass().addAll("default-window", "decorated-root"); //$NON-NLS-1$ //$NON-NLS-2$
Node dialogTitleBar = createTitleBar();
this.dialogAreaNode = (TitleAreaNode) dialogTitleBar;
registerTitleBar(dialogTitleBar);
this.titleProperty = ((TitleAreaNode) dialogTitleBar).titleProperty();
root.setTop(dialogTitleBar);
dialogTitleBar.applyCss();
sceneProperty().addListener((o) -> {
Scene s = getScene();
if (s != null) {
if (s.getWindow() != null) {
handleStageAttached();
} else {
s.windowProperty().addListener((o2) -> {
if (s.getWindow() != null) {
handleStageAttached();
}
});
}
}
});
this.trimPane = new BorderPane();
root.setCenter(this.trimPane);
this.contentProperty = this.trimPane.centerProperty();
return root;
}
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls
@SuppressWarnings("null")
@Override
protected Node createWindowArea() {
BorderPane root = new BorderPane();
getStyleClass().addAll("default-window", "decorated-root"); //$NON-NLS-1$ //$NON-NLS-2$
Node dialogTitleBar = createTitleBar();
this.dialogAreaNode = (TitleAreaNode) dialogTitleBar;
registerTitleBar(dialogTitleBar);
this.titleProperty = ((TitleAreaNode) dialogTitleBar).titleProperty();
root.setTop(dialogTitleBar);
dialogTitleBar.applyCss();
sceneProperty().addListener((o) -> {
Scene s = getScene();
if (s != null) {
if (s.getWindow() != null) {
handleStageAttached();
} else {
s.windowProperty().addListener((o2) -> {
if (s.getWindow() != null) {
handleStageAttached();
}
});
}
}
});
this.trimPane = new BorderPane();
root.setCenter(this.trimPane);
this.contentProperty = this.trimPane.centerProperty();
return root;
}
代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls
@SuppressWarnings("null")
@Override
protected Node createWindowArea() {
BorderPane root = new BorderPane();
getStyleClass().addAll("default-window", "decorated-root"); //$NON-NLS-1$ //$NON-NLS-2$
Node dialogTitleBar = createTitleBar();
this.dialogAreaNode = (TitleAreaNode) dialogTitleBar;
registerTitleBar(dialogTitleBar);
this.titleProperty = ((TitleAreaNode) dialogTitleBar).titleProperty();
root.setTop(dialogTitleBar);
dialogTitleBar.applyCss();
sceneProperty().addListener((o) -> {
Scene s = getScene();
if (s != null) {
if (s.getWindow() != null) {
handleStageAttached();
} else {
s.windowProperty().addListener((o2) -> {
if (s.getWindow() != null) {
handleStageAttached();
}
});
}
}
});
this.trimPane = new BorderPane();
root.setCenter(this.trimPane);
this.contentProperty = this.trimPane.centerProperty();
return root;
}
内容来源于网络,如有侵权,请联系作者删除!