当前位置: 首页>>代码示例>>Java>>正文


Java Shell.getBounds方法代码示例

本文整理汇总了Java中org.eclipse.swt.widgets.Shell.getBounds方法的典型用法代码示例。如果您正苦于以下问题:Java Shell.getBounds方法的具体用法?Java Shell.getBounds怎么用?Java Shell.getBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.widgets.Shell的用法示例。


在下文中一共展示了Shell.getBounds方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getCenteredPosition

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
/**
 * Get the centered position for a window according to its' parent Shell
 * and its' width and height.
 * @param myWidth The windows' width.
 * @param myHeight The windows' height.
 * @param parentShell The parent Shell.
 * @return An array containing the X and the Y position.
 */
public static int[] getCenteredPosition(int myWidth, int myHeight, Shell parentShell) {
	// Calculate the current position.
	Rectangle r = parentShell.getBounds();
	Rectangle displayBounds = parentShell.getDisplay().getBounds();
	int parentCenterX = r.x + (r.width / 2);
	int parentCenterY = r.y + (r.height / 2);
	int[] myPos = new int[2];
	myPos[0] = parentCenterX - (myWidth / 2);
	myPos[1] = parentCenterY - (myHeight / 2);

	// Leaving upper or left bounds?
	if (myPos[0] < 0) myPos[0] = 0;
	if (myPos[1] < 0) myPos[1] = 0;

	// Leaving lower or right bounds?
	if (myPos[0] > displayBounds.width - myWidth) myPos[0] = displayBounds.width - myWidth;
	if (myPos[1] > displayBounds.height - myHeight) myPos[1] = displayBounds.height - myHeight;

	// Finished.
	return myPos;
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:30,代码来源:StaticGuiSupport.java

示例3: getShellTitlebarHeight

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
/**
 * Get height of the shell's titlebar
 * @param s
 * @return
 */
public static int getShellTitlebarHeight(Shell s){
	Rectangle b = s.getBounds();
	Rectangle t = s.computeTrim(b.x, b.y, b.width, b.height);
	int tbarHeight = (b.y-t.y);
	return tbarHeight;
}
 
开发者ID:avoCADo-3d,项目名称:avoCADo,代码行数:12,代码来源:SWTUtils.java

示例4: getShellLeftEdgeWidth

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
/**
 * Get the width of the shell's left edge
 * @param s
 * @return
 */
public static int getShellLeftEdgeWidth(Shell s){
	Rectangle b = s.getBounds();
	Rectangle t = s.computeTrim(b.x, b.y, b.width, b.height);
	int leftEW = (b.x-t.x);
	if(s.getMaximized()){
		return 0;
	}else{
		return leftEW;
	}
}
 
开发者ID:avoCADo-3d,项目名称:avoCADo,代码行数:16,代码来源:SWTUtils.java

示例5: getShellRightEdgeWidth

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
/**
 * Get the width of the shell's right edge
 * @param s
 * @return
 */
public static int getShellRightEdgeWidth(Shell s){
	Rectangle b = s.getBounds();
	Rectangle t = s.computeTrim(b.x, b.y, b.width, b.height);
	int rightEW = ((t.width-b.width)-(b.x-t.x));
	if(s.getMaximized()){
		return 0;
	}else{
		return rightEW;
	}
}
 
开发者ID:avoCADo-3d,项目名称:avoCADo,代码行数:16,代码来源:SWTUtils.java

示例6: getShellBottomEdgeHeight

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
/**
 * Get the height of the shell's bottom edge
 * @param s
 * @return
 */
public static int getShellBottomEdgeHeight(Shell s){
	Rectangle b = s.getBounds();
	Rectangle t = s.computeTrim(b.x, b.y, b.width, b.height);
	int bottomEH = ((t.height-b.height)-(b.y-t.y));
	if(s.getMaximized()){
		return 0;
	}else{
		return bottomEH;
	}
}
 
开发者ID:avoCADo-3d,项目名称:avoCADo,代码行数:16,代码来源:SWTUtils.java

示例7: setCenter

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
public static void setCenter(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;
	}
	shell.setLocation(((screenW - shellW) / 2), ((screenH - shellH) / 2));
}
 
开发者ID:cnldw,项目名称:APITools,代码行数:14,代码来源:PubUtils.java

示例8: center

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
private void center(Shell shell) {

		Shell parent = (Shell) shell.getParent();
		Rectangle bounds = parent.getBounds();
		Point size = shell.getSize();

		int x = bounds.x + bounds.width / 2 - size.x / 2;
		int y = bounds.y + bounds.height / 2 - size.y / 2;
		// System.err.println("ChoiceDialog: center: x=" + x + " y=" + y);
		shell.setLocation(x, (y < 0) ? 0 : y);
	}
 
开发者ID:sergueik,项目名称:SWET,代码行数:12,代码来源:ChoicesDialog.java

示例9: center

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
private static Point center(Display display, Shell shell) {
	Monitor primary = display.getPrimaryMonitor();
	Rectangle bounds = primary.getBounds();
	Rectangle rect = shell.getBounds();

	int x = bounds.x + (bounds.width - rect.width) / 2;
	int y = bounds.y + (bounds.height - rect.height) / 2;

	Point location = new Point(x, y);
	return location;
}
 
开发者ID:sergueik,项目名称:SWET,代码行数:12,代码来源:ScrolledTextEx.java

示例10: launchXMLTextContainerWindow

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
/**
 * Launches the component property editor window for Unknown components. It is used to display XML content of Unknown
 * components on property window.
 * 
 * @return XML content of component. 
 */

public String launchXMLTextContainerWindow() {
	try{
		String xmlText = this.xmlText;
		Shell shell = new Shell(Display.getDefault().getActiveShell(), SWT.WRAP | SWT.MAX | SWT.APPLICATION_MODAL);

		shell.setLayout(new GridLayout(1, false));
		shell.setText("XML Content");
		shell.setSize(439, 432);
		text = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
		text.setEditable(false);
		text.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 250, 250, 250));
		if (this.xmlText != null) {
			xmlText = xmlText.substring(xmlText.indexOf('\n') + 1);
			xmlText = xmlText.substring(xmlText.indexOf('\n') + 1, xmlText.lastIndexOf('\n') - 13);

			text.setText(xmlText);
		} else
			text.setText(Messages.EMPTY_XML_CONTENT);
		GridData gd_text = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_text.widthHint = 360;
		gd_text.heightHint = 360;
		text.setLayoutData(gd_text);

		Monitor primary = shell.getDisplay().getPrimaryMonitor();
		Rectangle bounds = primary.getBounds();
		Rectangle rect = shell.getBounds();

		int x = bounds.x + (bounds.width - rect.width) / 2;
		int y = bounds.y + (bounds.height - rect.height) / 2;

		shell.setLocation(x, y);
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!shell.getDisplay().readAndDispatch()) {
				shell.getDisplay().sleep();
			}
		}
	}catch(Exception e)
	{
		LOGGER.error("Error occurred while creating XML text container widget", e);
	}
	return getXmlText();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:52,代码来源:XMLTextContainer.java

示例11: center

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
/**
 * Shell
 */
public static void center(final Shell shell) {
    final Rectangle r1 = shell.getMonitor().getBounds(), r2 = shell.getBounds();
    shell.setLocation(r1.x + (r1.width - r2.width) / 2, r1.y + (r1.height - r2.height) / 2);
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:8,代码来源:SwtUtils.java


注:本文中的org.eclipse.swt.widgets.Shell.getBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。