本文整理了Java中org.eclipse.swt.widgets.Monitor.getBounds()
方法的一些代码示例,展示了Monitor.getBounds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Monitor.getBounds()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Monitor
类名称:Monitor
方法名:getBounds
[英]Returns a rectangle describing the receiver's size and location relative to its device. Note that on multi-monitor systems the origin can be negative.
[中]返回一个矩形,描述接收器相对于其设备的大小和位置。请注意,在多监视器系统上,原点可能为负值。
代码示例来源:origin: pentaho/pentaho-kettle
Rectangle screenSize = display.getPrimaryMonitor().getBounds();
shell.setLocation( ( screenSize.width - shell.getBounds().width ) / 2, ( screenSize.height - shell.getBounds().height ) / 2 );
closeButton.setFocus();
代码示例来源:origin: pentaho/pentaho-kettle
protected Splash( Display display, Shell splashShell ) throws KettleException {
log = new LogChannel( Spoon.APP_NAME );
Rectangle displayBounds = display.getPrimaryMonitor().getBounds();
代码示例来源:origin: stackoverflow.com
Monitor widgetMonitor = mTextWidget.getMonitor();
Rectangle monitorRect = widgetMonitor.getBounds();
if(monitorRect.x < 0){
// shown in left monitor, starting from the main monitor
}
if(monitorRect.x > monitorRect.width){
// shown in right monitor, starting from the main monitor
}
代码示例来源:origin: com.github.rinde/rinsim-example
@Override
public void run() {
label.setText(monitor.getBounds().width + " x "
+ monitor.getBounds().height + "\n" + runner.getState());
}
});
代码示例来源:origin: rinde/RinSim
@Override
public void run() {
label.setText(monitor.getBounds().width + " x "
+ monitor.getBounds().height + "\n" + runner.getState());
}
});
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86
TouchSource findTouchSource (int /*long*/ touchDevice, Monitor monitor) {
if (touchSources == null) touchSources = new TouchSource [4];
int length = touchSources.length;
for (int i=0; i<length; i++) {
if (touchSources [i] != null && touchSources [i].handle == touchDevice) {
return touchSources [i];
}
}
int index = 0;
while (index < length) {
if (touchSources [index] == null) break;
index++;
}
if (index == length) {
TouchSource [] newTouchSources = new TouchSource [length + 4];
System.arraycopy (touchSources, 0, newTouchSources, 0, length);
touchSources = newTouchSources;
}
return touchSources [index] = new TouchSource (touchDevice, true, monitor.getBounds ());
}
代码示例来源:origin: be.yildiz-games/module-window-swt
/**
* Make the window use all the screen and remove the title bar.
*/
void setFullScreen() {
this.shell.setFullScreen(true);
this.shell.setFocus();
final Monitor m = Display.getDefault().getPrimaryMonitor();
this.shell.setBounds(-1, -1, m.getBounds().width + 2, m.getBounds().height + 2);
this.screenSize = new ScreenSize(m.getBounds().width, m.getBounds().height);
}
代码示例来源:origin: ystrot/glance
@Override
protected Point getInitialLocation(Point initialSize) {
Point location = getTargetLocation();
Point size = target.getSize();
int x = location.x + size.x / 2 - initialSize.x / 2;
int y = location.y + size.y;
Rectangle bounds = target.getMonitor().getBounds();
if (y + initialSize.y > bounds.y + bounds.height) {
y = location.y - initialSize.y;
}
return new Point(x, y);
}
代码示例来源:origin: com.diffplug.durian/durian-swt
/** Returns the monitor (if any) which contains the given point. */
public static Optional<Monitor> monitorFor(Point p) {
Monitor[] monitors = assertUI().getMonitors();
for (Monitor monitor : monitors) {
Rectangle bounds = monitor.getBounds();
if (bounds.contains(p)) {
return Optional.of(monitor);
}
}
return Optional.empty();
}
代码示例来源:origin: openaudible/openaudible
/**
* Either show or hide the fake tooltip. The tooltip will become visible in
* case the given tooltip is a valid URL (non strict match).
*
* @param tooltip The new value of the Tooltip
* @param control The control the tooltip is appearing on
*/
public void updateFakeTooltip(String tooltip, Control control) {
Rectangle rect = control.getMonitor().getBounds();
updateFakeTooltip(tooltip, rect, false);
}
代码示例来源:origin: openaudible/openaudible
public void updateFakeTooltip(String tooltip, Composite c) {
Rectangle rect = c.getMonitor().getBounds();
updateFakeTooltip(tooltip, rect, false);
}
代码示例来源:origin: openaudible/openaudible
public static void centerShell(Shell shell) {
Rectangle displayBounds = shell.getDisplay().getPrimaryMonitor().getBounds();
Rectangle shellBounds = shell.getBounds();
int x = displayBounds.x + (displayBounds.width - shellBounds.width) >> 1;
int y = displayBounds.y + (displayBounds.height - shellBounds.height) >> 1;
shell.setLocation(x, y);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.debug.ui
/**
* Increase the size of this dialog's <code>Shell</code> by the specified amounts.
* Do not increase the size of the Shell beyond the bounds of the Display.
*/
protected void setShellSize(int width, int height) {
Rectangle bounds = getShell().getMonitor().getBounds();
getShell().setSize(Math.min(width, bounds.width), Math.min(height, bounds.height));
}
代码示例来源:origin: org.codehaus.openxma/xmartclient
/**
* Centers the shell on the display.
* The used monitor will always the first one.
*/
protected void centerShell() {
Rectangle r = shell.getDisplay().getMonitors()[0].getBounds();
int shellX = (r.width - shell.getSize().x) / 2;
int shellY = (r.height - shell.getSize().y) / 2;
shell.setLocation(shellX, shellY);
}
代码示例来源:origin: org.codehaus.openxma/xmartserver
/**
* Centers the shell on the display.
* The used monitor will always the first one.
*/
protected void centerShell() {
Rectangle r = shell.getDisplay().getMonitors()[0].getBounds();
int shellX = (r.width - shell.getSize().x) / 2;
int shellY = (r.height - shell.getSize().y) / 2;
shell.setLocation(shellX, shellY);
}
代码示例来源:origin: tvrenamer/tvrenamer
private void positionWindow() {
// place the window near the lower right-hand corner
Monitor primary = display.getPrimaryMonitor();
Rectangle bounds = primary.getBounds();
Rectangle rect = shell.getBounds();
int x = bounds.x + (bounds.width - rect.width) - 5;
int y = bounds.y + (bounds.height - rect.height) - 35;
shell.setLocation(x, y);
}
代码示例来源:origin: openaudible/openaudible
/**
* Center a shell on the monitor
*
* @param display The display
* @param shell The shell to center
*/
public static void centerShell(Display display, Shell shell) {
Rectangle displayBounds = display.getPrimaryMonitor().getBounds();
Rectangle shellBounds = shell.getBounds();
int x = displayBounds.x + (displayBounds.width - shellBounds.width) >> 1;
int y = displayBounds.y + (displayBounds.height - shellBounds.height) >> 1;
shell.setLocation(x, y);
}
代码示例来源:origin: org.codehaus.openxma/xmartclient
/**
* Centers the given shell on the parent shell.
*
* If the parent shell is null, the shell is centered on the display.
*
* If more than one monitor is used, the shell is centered on the
* primary monitor.
*/
public static void centerShell(Shell parentShell, Shell shell) {
Rectangle parentRect;
Rectangle splashRect = shell.getBounds();
if (parentShell == null) {
parentRect = shell.getDisplay().getPrimaryMonitor().getBounds();
} else {
parentRect = parentShell.getBounds();
}
int x = parentRect.x + (parentRect.width - splashRect.width) / 2;
int y = parentRect.y + (parentRect.height - splashRect.height) / 2;
shell.setLocation(x, y);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
protected Point getInitialLocation(Point initialSize) {
if (getShell().getParent() == null) {
return super.getInitialLocation(initialSize);
}
Rectangle bounds = getShell().getParent().getMonitor().getBounds();
GC gc = new GC(getShell().getDisplay());
int textExtendX = gc.textExtent(message).x;
gc.dispose();
return new Point(bounds.x + bounds.width / 2 - textExtendX / 2, bounds.y + bounds.height / 5);
}
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
public void getChildAtPoint(AccessibleControlEvent e) {
NSPoint testPoint = new NSPoint();
testPoint.x = e.x;
Monitor primaryMonitor = Display.getCurrent().getPrimaryMonitor();
testPoint.y = (int) (primaryMonitor.getBounds().height - e.y);
Iterator iter = childRowToIdMap.values().iterator();
while (iter.hasNext()) {
AccessibleTableRow row = (AccessibleTableRow) iter.next();
NSValue locationValue = new NSValue(row.getPositionAttribute(ACC.CHILDID_SELF).id);
NSPoint location = locationValue.pointValue();
NSValue sizeValue = new NSValue(row.getSizeAttribute(ACC.CHILDID_SELF));
NSSize size = sizeValue.sizeValue();
if (location.y < testPoint.y && testPoint.y < (location.y + size.height)) {
AccessibleControlEvent e2 = new AccessibleControlEvent(e.getSource());
e2.x = (int) testPoint.x;
e2.y = (int) testPoint.y;
row.getChildAtPoint(e);
break;
}
}
}
内容来源于网络,如有侵权,请联系作者删除!