本文整理了Java中javafx.stage.Window
类的一些代码示例,展示了Window
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window
类的具体详情如下:
包路径:javafx.stage.Window
类名称:Window
暂无
代码示例来源:origin: jfoenixadmin/JFoenix
public void show(Window window, double x, double y, PopupVPosition vAlign, PopupHPosition hAlign, double initOffsetX, double initOffsetY) {
if (!isShowing()) {
if (window == null) {
throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window.");
}
Window parent = window;
final double anchorX = parent.getX() + x + initOffsetX;
final double anchorY = parent.getY() + y + initOffsetY;
this.show(parent, anchorX, anchorY);
((JFXPopupSkin) getSkin()).reset(vAlign, hAlign, initOffsetX, initOffsetY);
Platform.runLater(() -> ((JFXPopupSkin) getSkin()).animate());
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
private void fixPosition() {
Window w = dialog.getOwner();
Screen s = com.sun.javafx.util.Utils.getScreen(w);
Rectangle2D sb = s.getBounds();
double xR = w.getX() + w.getWidth();
double xL = w.getX() - dialog.getWidth();
double x;
double y;
if (sb.getMaxX() >= xR + dialog.getWidth()) {
x = xR;
} else if (sb.getMinX() <= xL) {
x = xL;
} else {
x = Math.max(sb.getMinX(), sb.getMaxX() - dialog.getWidth());
}
y = Math.max(sb.getMinY(), Math.min(sb.getMaxY() - dialog.getHeight(), w.getY()));
dialog.setX(x);
dialog.setY(y);
}
代码示例来源:origin: jfoenixadmin/JFoenix
@Override
protected double computePrefHeight(double width) {
Window owner = getOwner();
if (owner != null) {
return owner.getHeight();
} else {
return super.computePrefHeight(width);
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
private void addLayoutListeners() {
Window stage = getOwner();
if (stage != null) {
if (widthListener == null) {
throw new RuntimeException("Owner can only be set using the constructor");
}
stage.getScene().widthProperty().addListener(widthListener);
stage.getScene().heightProperty().addListener(heightListener);
stage.xProperty().addListener(xListener);
stage.yProperty().addListener(yListener);
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
private void updateX() {
Window stage = getOwner();
setX(stage.getX() + stage.getScene().getX());
}
代码示例来源:origin: jfoenixadmin/JFoenix
private void updateY() {
Window stage = getOwner();
setY(stage.getY() + stage.getScene().getY());
}
代码示例来源:origin: org.netbeans.html/net.java.html.boot.fx
@Override
public void handle(WindowEvent event) {
Window window = (Window) event.getSource();
prefs.putDouble("x", window.getX()); // NOI18N
prefs.putDouble("y", window.getY()); // NOI18N
prefs.putDouble("width", window.getWidth()); // NOI18N
prefs.putDouble("height", window.getHeight()); // NOI18N
}
};
代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls
/**
* Find a node in all windows
*
* @param w
* the preferred window
* @param screenX
* the screen x
* @param screenY
* the screen y
* @return the node or <code>null</code>
*/
@SuppressWarnings("deprecation")
public static Node findNode(Window w, double screenX, double screenY) {
// First check the owner
if (new BoundingBox(w.getX(), w.getY(), w.getWidth(), w.getHeight()).contains(screenX, screenY)) {
return findNode(w.getScene().getRoot(), screenX, screenY);
}
// FIXME If multiple match take the closest
Iterator<Window> impl_getWindows = Window.impl_getWindows();
while (impl_getWindows.hasNext()) {
Window window = impl_getWindows.next();
if (!FIND_NODE_EXCLUDE.equals(window.getUserData()) && new BoundingBox(window.getX(), window.getY(), window.getWidth(), window.getHeight()).contains(screenX, screenY)) {
return findNode(window.getScene().getRoot(), screenX, screenY);
}
}
return null;
}
代码示例来源:origin: com.miglayout/miglayout-javafx
/** Checks the parent window/popup if its size is within parameters as set by the LC.
*/
private void adjustWindowSize()
{
BoundSize wBounds = layoutConstraints.getPackWidth();
BoundSize hBounds = layoutConstraints.getPackHeight();
Scene scene = getScene();
Window window = scene != null ? scene.getWindow() : null;
if (window == null || wBounds == BoundSize.NULL_SIZE && hBounds == BoundSize.NULL_SIZE)
return;
Parent root = scene.getRoot();
double winWidth = window.getWidth();
double winHeight = window.getHeight();
double prefWidth = root.prefWidth(-1);
double prefHeight = root.prefHeight(-1);
FXContainerWrapper container = new FXContainerWrapper(root);
double horIns = winWidth - scene.getWidth();
double verIns = winHeight - scene.getHeight();
double targetW = constrain(container, winWidth, prefWidth, wBounds) + horIns;
double targetH = constrain(container, winHeight, prefHeight, hBounds) + verIns;
double x = window.getX() - ((targetW - winWidth) * (1 - layoutConstraints.getPackWidthAlign()));
double y = window.getY() - ((targetH - winHeight) * (1 - layoutConstraints.getPackHeightAlign()));
window.setX(x);
window.setY(y);
window.setWidth(targetW);
window.setHeight(targetH);
}
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls
if( getScene() != null && getScene().getWindow() != null ) {
Window w = getScene().getWindow();
getScene().getWindow().setWidth(Util.unsignedConstraintValue(w.getWidth(), getMinWidth(), getMaxWidth()));
if( getScene() != null && getScene().getWindow() != null ) {
Window w = getScene().getWindow();
getScene().getWindow().setHeight(Util.unsignedConstraintValue(w.getHeight(), getMinHeight(), getMaxHeight()));
this.windowProperty.addListener((o, oldV, newV) -> {
if (oldV != null) {
oldV.widthProperty().removeListener(this::handleStageChange);
oldV.heightProperty().removeListener(this::handleStageChange);
oldV.xProperty().removeListener(this::handleStageChange);
oldV.yProperty().removeListener(this::handleStageChange);
newV.widthProperty().addListener(this::handleStageChange);
newV.heightProperty().addListener(this::handleStageChange);
newV.xProperty().addListener(this::handleStageChange);
newV.yProperty().addListener(this::handleStageChange);
代码示例来源:origin: torakiki/pdfsam
private void showPasswordFieldPopup() {
Scene scene = this.getScene();
if (scene != null) {
Window owner = scene.getWindow();
if (owner != null && owner.isShowing()) {
Point2D nodeCoord = encryptionIndicator.localToScene(encryptionIndicator.getWidth() / 2,
encryptionIndicator.getHeight() / 1.5);
double anchorX = Math.round(owner.getX() + scene.getX() + nodeCoord.getX() + 2);
double anchorY = Math.round(owner.getY() + scene.getY() + nodeCoord.getY() + 2);
passwordPopup.showFor(this, descriptor, anchorX, anchorY);
}
}
}
代码示例来源:origin: org.controlsfx/controlsfx
getPopupWindow().xProperty().addListener(updatePathListener);
getPopupWindow().yProperty().addListener(updatePathListener);
popOver.arrowLocationProperty().addListener(updatePathListener);
popOver.contentNodeProperty().addListener(
window.setX(window.getX() + deltaX);
window.setY(window.getY() + deltaY);
代码示例来源:origin: org.copper-engine/copper-monitoring-client
@Override
public void run() {
Window dialog = previewPane.getScene().getWindow();
double currWidth = dialog.getWidth();
double currHeight = dialog.getHeight();
dialog.setWidth(Math.max(currWidth, 20 + previewPane.getLayoutX() + previewPane.getPrefWidth()));
dialog.setHeight(20 + currHeight + previewPane.getPrefHeight());
updatePreview();
}
代码示例来源:origin: jfoenixadmin/JFoenix
private void updateWidth() {
Window stage = getOwner();
setWidth(stage.getScene().getWidth());
}
代码示例来源:origin: org.tentackle/tentackle-fx
/**
* Calculates the location of a window so that it will be centered on the screen.
*
* @param window the window
* @return the location (top left corner)
*/
public Point2D determineCenteredLocation(Window window) {
Rectangle2D screenSize = Screen.getPrimary().getVisualBounds();
// align sizes (for computation below)
double windowWidth = window.getWidth();
double windowHeight = window.getHeight();
if (window.getWidth() > screenSize.getWidth()) {
windowWidth = screenSize.getWidth();
}
if (windowHeight > screenSize.getHeight()) {
windowHeight = screenSize.getHeight();
}
return new Point2D((screenSize.getWidth() - windowWidth) / 2.0,
(screenSize.getHeight() - windowHeight) / 2.0);
}
代码示例来源:origin: org.controlsfx/controlsfx
ownerWindow.xProperty().removeListener(weakXListener);
ownerWindow.yProperty().removeListener(weakYListener);
ownerWindow.widthProperty().removeListener(weakHideListener);
ownerWindow.heightProperty().removeListener(weakHideListener);
ownerWindow.xProperty().addListener(weakXListener);
ownerWindow.yProperty().addListener(weakYListener);
ownerWindow.widthProperty().addListener(weakHideListener);
ownerWindow.heightProperty().addListener(weakHideListener);
ownerWindow.addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST,
closePopOverOnOwnerWindowClose);
ownerWindow.addEventFilter(WindowEvent.WINDOW_HIDING,
closePopOverOnOwnerWindowClose);
代码示例来源:origin: org.jfxtras/jfxtras-common
/**
*
* @param node
* @return The Y screen coordinate of the node.
*/
static public double screenY(Node node) {
return sceneY(node) + node.getScene().getWindow().getY();
}
代码示例来源:origin: org.jfxtras/jfxtras-common
/**
*
* @param node
* @return The X screen coordinate of the node.
*/
static public double screenX(Node node) {
return sceneX(node) + node.getScene().getWindow().getX();
}
代码示例来源:origin: jfoenixadmin/JFoenix
@Override
protected double computePrefWidth(double height) {
Window owner = getOwner();
if (owner != null) {
return owner.getWidth();
} else {
return super.computePrefWidth(height);
}
}
代码示例来源:origin: com.guigarage/responsivefx
public static void bindStyleSheetToWindow(Window window, StringProperty stylesheet) {
window.sceneProperty().addListener(e -> {
if (window.getScene() != null) {
window.getScene().getStylesheets().add(stylesheet.get());
}
});
if (window.getScene() != null) {
window.getScene().getStylesheets().add(stylesheet.get());
}
stylesheet.addListener((obs, o, n) -> {
if (window.getScene() != null) {
int oldPos = -1;
if (o != null) {
oldPos = window.getScene().getStylesheets().indexOf(o);
window.getScene().getStylesheets().remove(o);
}
if (n != null) {
if (oldPos >= 0) {
window.getScene().getStylesheets().add(oldPos, n);
} else {
window.getScene().getStylesheets().add(n);
}
}
}
});
}
}
内容来源于网络,如有侵权,请联系作者删除!