當前位置: 首頁>>代碼示例>>Java>>正文


Java Dialog.setY方法代碼示例

本文整理匯總了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);
		}));
	}
 
開發者ID:lestard,項目名稱:structured-list,代碼行數:29,代碼來源:DialogUtil.java

示例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);
}
 
開發者ID:Adrodoc55,項目名稱:MPL,代碼行數:5,代碼來源:JavaFxUtils.java

示例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);
}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:20,代碼來源:DialogHelper.java


注:本文中的javafx.scene.control.Dialog.setY方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。