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


Java Display.getCursorLocation方法代碼示例

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


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

示例1: configureShell

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
@Override
public void configureShell(Shell newShell) {
	super.configureShell(newShell);
	newShell.setText("Limit chars logs");
	newShell.setSize(nWidth, nHeight);

	int nLeft = 0;
	int nTop = 0;

	Display display = newShell.getDisplay();

	Point pt = display.getCursorLocation();
	Monitor[] monitors = display.getMonitors();

	for (int i = 0; i < monitors.length; i++) {
		if (monitors[i].getBounds().contains(pt)) {
			Rectangle rect = monitors[i].getClientArea();

			if (rect.x < 0)
				nLeft = ((rect.width - nWidth) / 2) + rect.x;
			else
				nLeft = (rect.width - nWidth) / 2;

			if (rect.y < 0)
				nTop = ((rect.height - nHeight) / 2) + rect.y;
			else
				nTop = (rect.height - nHeight) / 2;

			break;
		}
	}

	newShell.setBounds(nLeft, nTop, nWidth, nHeight);
	
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:36,代碼來源:LimitCharsLogsPreferenceDialog.java

示例2: configureShell

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
@Override
public void configureShell(Shell newShell) {
	super.configureShell(newShell);
	newShell.setText("Parameters availables");
	newShell.setSize(nWidth, nHeight);

	int nLeft = 0;
	int nTop = 0;

	Display display = newShell.getDisplay();

	Point pt = display.getCursorLocation();
	Monitor[] monitors = display.getMonitors();

	for (int i = 0; i < monitors.length; i++) {
		if (monitors[i].getBounds().contains(pt)) {
			Rectangle rect = monitors[i].getClientArea();

			if (rect.x < 0)
				nLeft = ((rect.width - nWidth) / 2) + rect.x;
			else
				nLeft = (rect.width - nWidth) / 2;

			if (rect.y < 0)
				nTop = ((rect.height - nHeight) / 2) + rect.y;
			else
				nTop = (rect.height - nHeight) / 2;

			break;
		}
	}

	newShell.setBounds(nLeft, nTop, nWidth, nHeight);
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:35,代碼來源:CouchVariablesDialog.java

示例3: configureShell

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
@Override
	public void configureShell(Shell newShell) {
		super.configureShell(newShell);
		
		newShell.setText(dialogTitle);	
		
		int nLeft = 0;
		int nTop = 0;
		 
		Display display = newShell.getDisplay();

//		// mods jmc 22/10/2013
//		nWidth = newShell.getSize().x;
//		nHeight = newShell.getSize().y;
		
		Point pt = display.getCursorLocation();
	    Monitor [] monitors = display.getMonitors();

	    for (int i= 0; i<monitors.length; i++) {
	          if (monitors[i].getBounds().contains(pt)) {
	             Rectangle rect = monitors[i].getClientArea();
	             
	             if (rect.x < 0)
	         		nLeft = ((rect.width - nWidth) / 2) + rect.x;
	             else
	         		nLeft = (rect.width - nWidth) / 2;

	             if (rect.y < 0)
	         		nTop = ((rect.height - nHeight) / 2) + rect.y;
	             else
	         		nTop = (rect.height - nHeight) / 2;
	             
	             break;
	          }
	    }

	    newShell.setBounds(nLeft, nTop, nWidth, nHeight);
	}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:39,代碼來源:MyAbstractDialog.java

示例4: configureShell

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
@Override
public void configureShell(Shell newShell) {
	super.configureShell(newShell);
	newShell.setText("Engine Log settings");
	newShell.setSize(nWidth, nHeight);

	int nLeft = 0;
	int nTop = 0;

	Display display = newShell.getDisplay();

	Point pt = display.getCursorLocation();
	Monitor[] monitors = display.getMonitors();

	for (int i = 0; i < monitors.length; i++) {
		if (monitors[i].getBounds().contains(pt)) {
			Rectangle rect = monitors[i].getClientArea();

			if (rect.x < 0)
				nLeft = ((rect.width - nWidth) / 2) + rect.x;
			else
				nLeft = (rect.width - nWidth) / 2;

			if (rect.y < 0)
				nTop = ((rect.height - nHeight) / 2) + rect.y;
			else
				nTop = (rect.height - nHeight) / 2;

			break;
		}
	}

	newShell.setBounds(nLeft, nTop, nWidth, nHeight);
	
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:36,代碼來源:EnginePreferenceDialog.java

示例5: performPostDialogCreation

import org.eclipse.swt.widgets.Display; //導入方法依賴的package包/類
@Override
public void performPostDialogCreation() {
	// mods jmc 26/07/2013
			
	int nWidth;
	int nHeight;
	int nLeft = 0;
	int nTop = 0;
	 
	Shell newShell = this.parentDialog.getShell();

	// mods jmc 22/10/2013
	nWidth = (int) (0.50 * newShell.getSize().x);
	nHeight = (int) (0.60 * newShell.getSize().y);
	Display display = newShell.getDisplay();
	
	Point pt = display.getCursorLocation();
    Monitor [] monitors = display.getMonitors();

    for (int i= 0; i<monitors.length; i++) {
          if (monitors[i].getBounds().contains(pt)) {
             Rectangle rect = monitors[i].getClientArea();
             
             if (rect.x < 0)
         		nLeft = ((rect.width - nWidth) / 2) + rect.x;
             else
         		nLeft = (rect.width - nWidth) / 2;

             if (rect.y < 0)
         		nTop = ((rect.height - nHeight) / 2) + rect.y;
             else
         		nTop = (rect.height - nHeight) / 2;
             
             break;
          }
    }

    newShell.setBounds(nLeft, nTop, nWidth, nHeight);
	
	super.performPostDialogCreation();
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:42,代碼來源:SqlQueryEditorComposite.java


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