本文整理匯總了Java中org.eclipse.swt.widgets.Shell.getSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Shell.getSize方法的具體用法?Java Shell.getSize怎麽用?Java Shell.getSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.Shell
的用法示例。
在下文中一共展示了Shell.getSize方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setLocation
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
/**
*
*/
protected void setLocation(final XCalendar popup) {
//
final Shell shell = popup.getShell();
final Display display = popup.getDisplay();
final Rectangle r1 = display.map(prevParent, null, prevBounds);
final Rectangle r2 = popup.getMonitor().getClientArea(); // Client area
//
final int margin = 2;
final Point size = shell.getSize();
int x = r1.x, y = r1.y + r1.height + margin;
if(y + size.y > r2.y + r2.height) y = r1.y - size.y - margin;
if(x < r2.x) x = r2.x; else if(x + size.x > r2.x + r2.width) x = r2.x + r2.width - size.x;
shell.setLocation(x, y);
}
示例2: handleAdvancedButtonSelect
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
/**
* Shows/hides the advanced option widgets.
*/
protected void handleAdvancedButtonSelect() {
Shell shell = getShell();
Point shellSize = shell.getSize();
Composite composite = (Composite) getControl();
if (linkedResourceComposite != null) {
linkedResourceComposite.dispose();
linkedResourceComposite = null;
composite.layout();
shell.setSize(shellSize.x, shellSize.y - linkedResourceGroupHeight);
advancedButton.setText(IDEWorkbenchMessages.showAdvanced);
} else {
linkedResourceComposite = linkedResourceGroup
.createContents(linkedResourceParent);
setupLinkedResourceTarget();
if (linkedResourceGroupHeight == -1) {
Point groupSize = linkedResourceComposite.computeSize(
SWT.DEFAULT, SWT.DEFAULT, true);
linkedResourceGroupHeight = groupSize.y;
}
shell.setSize(shellSize.x, shellSize.y + linkedResourceGroupHeight);
composite.layout();
advancedButton.setText(IDEWorkbenchMessages.hideAdvanced);
}
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
}
}
示例6: performPostDialogCreation
import org.eclipse.swt.widgets.Shell; //導入方法依賴的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();
}
示例7: resize
import org.eclipse.swt.widgets.Shell; //導入方法依賴的package包/類
public static void resize(Shell shell, @Nullable Integer width, @Nullable Integer height) {
final Point s = shell.getSize();
int w = width == null ? s.x : width, h = height == null ? s.y : height; shell.setSize(new Point(w, h));
}