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


Java Shell.getLocation方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.Shell.getLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java Shell.getLocation方法的具體用法?Java Shell.getLocation怎麽用?Java Shell.getLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.Shell的用法示例。


在下文中一共展示了Shell.getLocation方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setCenterinParent

import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public static void setCenterinParent(Shell parentshell, Shell shell) {
	int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
	int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
	int shellH = shell.getBounds().height;
	int shellW = shell.getBounds().width;
	// 如果窗口大小超過屏幕大小,調整為屏幕大小
	if (shellH > screenH) {
		shellH = screenH;
	}
	if (shellW > screenW) {
		shellW = screenW;
	}
	int targetx = parentshell.getLocation().x + parentshell.getBounds().width / 2 - shell.getBounds().width / 2;
	int targety = parentshell.getLocation().y + parentshell.getBounds().height / 2 - shell.getBounds().height / 2;
	if (targetx + shellW > screenW) {
		targetx = screenW - shellW;
	}
	if (targety + shellH > screenH) {
		targety = screenH - shellH;
	}
	shell.setLocation(targetx, targety);
}
 
開發者ID:cnldw,項目名稱:APITools,代碼行數:23,代碼來源:PubUtils.java

示例2: center

import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
/**
 * Center the child shell within the parent shell window.
 */
public static void center(Shell parent, Shell child) {
	int x = parent.getLocation().x + 
		(parent.getSize().x - child.getSize().x) / 2;
	int y = parent.getLocation().y +
		(parent.getSize().y - child.getSize().y) / 2;
	if (x < 0) x = 0;
	if (y < 0) y = 0;
	child.setLocation(x,y);
}
 
開發者ID:AppleCommander,項目名稱:AppleCommander,代碼行數:13,代碼來源:SwtUtil.java

示例3: saveDialogBounds

import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
/**
 * Saves the bounds of the shell in the appropriate dialog settings. The
 * bounds are recorded relative to the parent shell, if there is one, or
 * display coordinates if there is no parent shell. Subclasses typically
 * need not override this method, but may extend it (calling
 * <code>super.saveDialogBounds</code> if additional bounds information
 * should be stored. Clients may also call this method to persist the bounds
 * at times other than closing the dialog.
 * 
 * @param shell
 *            The shell whose bounds are to be stored
 */
protected void saveDialogBounds(Shell shell) {
	IDialogSettings settings = getDialogSettings();
	if (settings != null) {
		Point shellLocation = shell.getLocation();
		Point shellSize = shell.getSize();
		Shell parent = getParentShell();
		if (parent != null) {
			Point parentLocation = parent.getLocation();
			shellLocation.x -= parentLocation.x;
			shellLocation.y -= parentLocation.y;
		}
		String prefix = getClass().getName();
		if (persistSize) {
			settings.put(prefix + DIALOG_WIDTH, shellSize.x);
			settings.put(prefix + DIALOG_HEIGHT, shellSize.y);
		}
		if (persistLocation) {
			settings.put(prefix + DIALOG_ORIGIN_X, shellLocation.x);
			settings.put(prefix + DIALOG_ORIGIN_Y, shellLocation.y);
		}
		if (showPersistActions && showDialogMenu) {
			settings.put(getClass().getName() + DIALOG_USE_PERSISTED_SIZE,
					persistSize);
			settings.put(getClass().getName() + DIALOG_USE_PERSISTED_LOCATION,
					persistLocation);

		}
	}
}
 
開發者ID:sergueik,項目名稱:SWET,代碼行數:42,代碼來源:PopupDialog.java


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