当前位置: 首页>>代码示例>>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;未经允许,请勿转载。