本文整理汇总了Java中org.eclipse.swt.widgets.Monitor.getBounds方法的典型用法代码示例。如果您正苦于以下问题:Java Monitor.getBounds方法的具体用法?Java Monitor.getBounds怎么用?Java Monitor.getBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.Monitor
的用法示例。
在下文中一共展示了Monitor.getBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDialogArea
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
@Override
protected Control createDialogArea(Composite parent)
{
parent.setBackgroundMode(SWT.INHERIT_DEFAULT);
parent.setBackground(BTSUIConstants.VIEW_BACKGROUND_DESELECTED_COLOR);
Composite control = createContentArea(parent);
control.setData("org.eclipse.e4.ui.css.id", "LoginDialog");
Rectangle controlRect = control.getBounds();
// looks strange in multi monitor environments
// Rectangle displayBounds = shell.getDisplay().getBounds();
shell.getDisplay();
Monitor primary = Display.getDefault().getPrimaryMonitor();
Rectangle displayBounds = primary.getBounds();
int x = (displayBounds.width - controlRect.width) / 2;
int y = (displayBounds.height - controlRect.height) / 2;
shell.setBounds(x, y, controlRect.width, controlRect.height);
return control;
}
示例2: initShell
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
private void initShell() {
shell = new Shell(Display.getCurrent(), SWT.APPLICATION_MODAL
| SWT.SHEET);
shell.setText("Feature-Expression Management Dialog");
shell.setImage(VariantSyncPlugin.getDefault()
.getImageDescriptor("icons/featureExpression.png")
.createImage());
shell.setSize(500, 485);
GridLayout shellLayout = new GridLayout();
shellLayout.marginWidth = 0;
shellLayout.marginHeight = 0;
shell.setLayout(shellLayout);
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);
}
示例3: getDisplayBounds
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
private Rectangle getDisplayBounds(final Point location) {
Rectangle displayBounds;
final Monitor[] allMonitors = _ownerControl.getDisplay().getMonitors();
if (allMonitors.length > 1) {
// By default present in the monitor of the control
displayBounds = _ownerControl.getMonitor().getBounds();
final Point p = new Point(location.x, location.y);
// Search on which monitor the event occurred
Rectangle tmp;
for (final Monitor element : allMonitors) {
tmp = element.getBounds();
if (tmp.contains(p)) {
displayBounds = tmp;
break;
}
}
} else {
displayBounds = _ownerControl.getDisplay().getBounds();
}
return displayBounds;
}
示例4: getDisplayBounds
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
public static Rectangle getDisplayBounds(final Control composite, final Point location) {
Rectangle displayBounds;
final Monitor[] allMonitors = composite.getDisplay().getMonitors();
if (allMonitors.length > 1) {
// By default present in the monitor of the control
displayBounds = composite.getMonitor().getBounds();
final Point p = new Point(location.x, location.y);
// Search on which monitor the event occurred
Rectangle tmp;
for (final Monitor element : allMonitors) {
tmp = element.getBounds();
if (tmp.contains(p)) {
displayBounds = tmp;
break;
}
}
} else {
displayBounds = composite.getDisplay().getBounds();
}
return displayBounds;
}
示例5: configureShell
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText("JIsoCreator");
shell.setSize(800, 600);
shell.setImage(ImageUtils.getInstance().loadImage("iso.png"));
Monitor primary = Display.getCurrent().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);
}
示例6: center
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的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;
}
示例7: center
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
/**
* Centers the shell on the given monitor.
*
* @param shell
* @param monitor
*/
public static void center(Shell shell, Monitor monitor) {
Rectangle shellRect = shell.getBounds();
Rectangle displayRect = monitor.getBounds();
int x = (displayRect.width - shellRect.width) / 2;
int y = (displayRect.height - shellRect.height) / 2;
shell.setLocation(displayRect.x + x, displayRect.y + y);
}
示例8: center
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
public void center() {
Monitor primary = Display.getCurrent().getPrimaryMonitor();
Rectangle bounds = primary.getBounds();
Rectangle rect = getShell().getBounds();
int x = bounds.x + (bounds.width - rect.width) / 2;
int y = bounds.y + (bounds.height - rect.height) / 2;
getShell().setLocation(x, y);
}
示例9: centerShell
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
public static void centerShell(Shell shell) {
Display display = shell.getDisplay();
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;
shell.setLocation(x, y);
}
示例10: setLocation
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
private void setLocation(Display display, Shell shell)
{
Monitor monitor = display.getPrimaryMonitor();
Rectangle monitorRect = monitor.getBounds();
Rectangle shellRect = shell.getBounds();
int x = monitorRect.x + (monitorRect.width - shellRect.width) / 2;
int y = monitorRect.y + (monitorRect.height - shellRect.height) / 2;
shell.setLocation(x, y);
}
示例11: getMonitorCenter
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
private Point getMonitorCenter(Shell shell)
{
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;
return new Point(x, y);
}
示例12: initShell
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
/**
* initializes the shell
*/
private void initShell() {
shell = new Shell(Display.getCurrent(), SWT.APPLICATION_MODAL
| SWT.SHEET);
shell.setText(DEFAULT_DIALOG_TITLE);
shell.setImage(VariantSyncPlugin.getDefault()
.getImageDescriptor("icons/featureExpression.png")
.createImage());
shell.setSize(500, 585);
GridLayout shellLayout = new GridLayout();
shellLayout.marginWidth = 0;
shellLayout.marginHeight = 0;
shell.setLayout(shellLayout);
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.addListener(SWT.Traverse, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.TRAVERSE_ESCAPE
&& !adapter.isProposalPopupOpen()) {
closeButtonPressEvent();
}
}
});
}
示例13: initializeBounds
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
@Override
protected void initializeBounds() {
super.initializeBounds();
Shell shell = getShell();
Monitor primary = shell.getMonitor();
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);
}
示例14: getInitialLocation
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
@Override
protected Point getInitialLocation(Point initialSize) {
Monitor primaryMonitor = Display.getDefault().getPrimaryMonitor();
Rectangle bounds = primaryMonitor.getBounds();
int x = bounds.x + (bounds.width) / 2 - getShell().getSize().x / 2;
int y = bounds.y + (bounds.height) / 2 - getShell().getSize().y / 2;
return new Point(x, y);
}
示例15: show
import org.eclipse.swt.widgets.Monitor; //导入方法依赖的package包/类
public void show(Rectangle r) {
dialog = setDialogLayout();
dialog.pack();
UIUtil.setDialogDefaultFunctions(dialog);
if (p.tags.size() > 0) {
dialog.setSize(600, 400);
} else {
dialog.setSize(600, 300);
}
int timeout = PManager.getInstance().getInt(PreferenceConstants.P_ALERT_DIALOG_TIMEOUT);
if (timeout > 0) {
timer = new Timer(true);
timer.schedule(new TimerTask() {
public void run() {
ExUtil.exec(dialog, new Runnable() {
public void run() {
close();
}
});
}
}, timeout * 1000);
}
Monitor primaryMonitor = display.getPrimaryMonitor ();
Rectangle bounds = primaryMonitor.getBounds ();
Rectangle rect = dialog.getBounds ();
int x = bounds.x + (bounds.width - rect.width) / 2 ;
int y = bounds.y + (bounds.height - rect.height) / 2 ;
dialog.setLocation (x, y);
dialog.open();
}