本文整理汇总了Java中javafx.scene.control.Dialog.setY方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.setY方法的具体用法?Java Dialog.setY怎么用?Java Dialog.setY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Dialog
的用法示例。
在下文中一共展示了Dialog.setY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initDialogPositioning
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static void initDialogPositioning(Dialog dialog) {
final double windowX = applicationWindow == null ? 0.0 : applicationWindow.getX();
final double windowY = applicationWindow == null ? 0.0 : applicationWindow.getY();
// initially position the dialog on the window
dialog.setX(windowX);
dialog.setY(windowY);
// after the dialog is visible we can move it to the middle of the window.
dialog.setOnShown(e -> Platform.runLater(() -> {
final double windowWidth = applicationWindow == null ? 1000 : applicationWindow.getWidth();
final double windowHeight = applicationWindow == null ? 500 : applicationWindow.getHeight();
final double dialogWidth = dialog.getWidth();
final double dialogHeight = dialog.getHeight();
final double offsetX = (windowWidth - dialogWidth) / 2;
final double offsetY = (windowHeight - dialogHeight) / 2;
final double dialogX = windowX + offsetX;
final double dialogY = windowY + offsetY;
dialog.setX(dialogX);
dialog.setY(dialogY);
}));
}
示例2: centerOnOwner
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static void centerOnOwner(Dialog<?> dialog, Window owner) {
dialog.setX(owner.getX() + owner.getWidth() / 2 - dialog.getWidth() / 2);
dialog.setY(owner.getY() + owner.getHeight() / 2 - dialog.getHeight() / 2);
}
示例3: positionDialog
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/** Position dialog relative to another widget
*
* <p>By default, dialogs seem to pop up in the center of the first monitor.
* .. even if the "current" window is on a different monitor.
*
* <p>This helper positions the dialog relative to the center
* of a node.
*
* @param dialog Dialog to position
* @param node Node relative to which dialog should be positioned
* @param x_offset Offset relative to center of the node
* @param y_offset Offset relative to center of the node
*/
public static void positionDialog(final Dialog<?> dialog, final Node node, final int x_offset, final int y_offset)
{
final Bounds pos = node.localToScreen(node.getBoundsInLocal());
dialog.setX(pos.getMinX() + pos.getWidth()/2 + x_offset);
dialog.setY(pos.getMinY() + pos.getHeight()/2 + y_offset);
}