private void centerShell(Shell parent, Shell shell) { Rectangle parentBounds = parent.getBounds(); Rectangle childBounds = shell.getBounds(); int x = parentBounds.x + (parentBounds.width - childBounds.width) / 2; int y = parentBounds.y + (parentBounds.height - childBounds.height) / 2; shell.setLocation(x, y); }
/** * Centralizes a window on the screen * * @param shell the window */ private static void centralizeShell(Shell shell) { int width = shell.getSize().x; int height = shell.getSize().y; int x = (shell.getDisplay().getClientArea().width - width) / 2; int y = (shell.getDisplay().getClientArea().height - height) / 2; shell.setLocation(x, y); }
public InputViewer(Shell parent, Properties properties, String resources) { sShell = new org.eclipse.swt.widgets.Shell(parent); sShell.setLocation(parent.getLocation().x + 200, parent.getLocation().y + 150); sShell.setSize(new org.eclipse.swt.graphics.Point(471, 146)); sShell.setLayout(null); listeners = new Vector<DialogInputListener>(); ApplicationFactory factory = new ApplicationFactory(sShell, resources, getClass().getName()); factory.createLabel("lbl").setBounds(15, 15, 100, 20); txtName = factory.createText(); txtName.setBounds(120, 15, 280, 20); txtName.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.keyCode != 13) return; enter(); } }); factory .createButton( "but", new SelectionAdapter() { @SuppressWarnings("unused") public void widgetSelected(SelectionEvent e) { enter(); } }) .setBounds(180, 50, 90, 20); sShell.setSize(420, 120); sShell.open(); }
protected void openDialog() { if (Const.isWindows()) { shell.setSize(653, 671); } if (Const.isLinux()) { shell.setSize(740, 678); } if (Const.isOSX()) { shell.setSize(653, 678); } // Set the focus on the OK button wOK.setFocus(); shell.open(); Rectangle shellBounds = getParent().getBounds(); Point dialogSize = shell.getSize(); shell.setLocation( shellBounds.x + (shellBounds.width - dialogSize.x) / 2, shellBounds.y + (shellBounds.height - dialogSize.y) / 2); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
public BarSettings open(Point location) { shell = new Shell(parent.getShell(), SWT.DIALOG_TRIM); shell.setText(MainGui.APP_NAME + " - Trend Display Settings ..."); shell.addDisposeListener( new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { MainPMScmd.getMyPrefs().flushy(); } }); initGui(); shell.setLocation(location); shell.layout(); shell.pack(); shell.open(); return barChartSettings; }
/** Create contents of the dialog. */ private void createContents() { shell = new Shell(getParent(), getStyle()); shell.setLocation(location); shell.setSize(132, 85); shell.setText(getText()); final Combo combo = new Combo(shell, SWT.NONE); combo.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { System.out.println(combo.getItem(combo.getSelectionIndex())); MSA structure = worksheet_.getStructure(); int no = Integer.parseInt(combo.getItem(combo.getSelectionIndex())); try { element_.setMaterial(structure.getMaterialByNo(no)); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } shell.dispose(); } }); combo.setBounds(0, 0, 100, 40); for (Material material : this.worksheet_.getStructure().getMaterials()) { combo.add(String.valueOf(material.getNo())); } // combo.add("1223"); // combo.add("343"); // combo.setBounds(20, 10, 88, 23); }
/** Center the supplied Shell */ public static void centerShell(Shell shell) { Display d = shell.getDisplay(); Rectangle db = d.getBounds(); Rectangle sb = shell.getBounds(); int xoffset = (db.width - sb.width) / 2; int yoffset = (db.height - sb.height) / 2; shell.setLocation(xoffset, yoffset); }
public static void placeDialogInCenter(Shell parent, Shell shell) { Rectangle parentSize = parent.getBounds(); Rectangle mySize = shell.getBounds(); int locationX, locationY; locationX = (parentSize.width - mySize.width) / 2 + parentSize.x; locationY = (parentSize.height - mySize.height) / 2 + parentSize.y; shell.setLocation(new Point(locationX, locationY)); }
public String open() { Shell shell = new Shell(getParent(), getStyle()); shell.setText("Add project"); createContents(shell); shell.pack(); shell.setLocation(100, 100); shell.open(); return null; }
private static void center() { Rectangle bounds = GameOfLife.PRIMARY_MONITOR.getBounds(); Rectangle rect = askShell.getBounds(); int x = bounds.x + (bounds.width - rect.width) / 2; int y = bounds.y + (bounds.height - rect.height) / 2; askShell.setLocation(x, y); }
/** Test {@link SitarWindow#getX()} and {@link SitarWindow#getY()}. */ @Test public void testShellLocation() { Shell shell = new Shell(display); shell.setLocation(1, 1); SitarWindow swtWindow = new SitarWindow(shell); assertEquals(swtWindow.getX(), 0); assertEquals(swtWindow.getY(), 0); }
/** Create contents of the dialog. */ private void createContents() { shell = new Shell(getParent(), getStyle()); shell.setSize(1200, 500); shell.setText("\u67E5\u770B\u7B7E\u540D"); shell.setLayout(new FillLayout(SWT.HORIZONTAL)); shell.setLocation( (Display.getDefault().getBounds().width - shell.getBounds().width) / 2, (Display.getDefault().getBounds().height - shell.getBounds().height) / 2); }
@Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(Messages.GenerateReportDialog_4); // open the window right under the mouse pointer: Point cursorLocation = Display.getCurrent().getCursorLocation(); newShell.setLocation(new Point(cursorLocation.x - SIZE_X / 2, cursorLocation.y - SIZE_Y / 2)); }
@Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText(Messages.COMPILELOADER); Rectangle parentBounds = parentShell.getBounds(); Rectangle shellBounds = newShell.getBounds(); newShell.setLocation( parentBounds.x + (parentBounds.width - shellBounds.width) / 2, parentBounds.y + (parentBounds.height - shellBounds.height) / 2); }
@Override protected void configureShell(Shell shell) { super.configureShell(shell); Shell s2 = shell.getParent().getShell(); if (s2 != null) shell.setLocation(s2.getLocation()); shell.setBounds(shell.getLocation().x, shell.getLocation().y, 550, 500); if (domain == null) shell.setText(CredentialMessages.AddACredentialDomain); else { shell.setText(CredentialMessages.EditACredentialDomain); } }
public void show(int serverId, Rectangle r) { dialog = setDialogLayout(serverId); dialog.pack(); UIUtil.setDialogDefaultFunctions(dialog); getOldDescription(); dialog.setSize(400, 150); dialog.setLocation(r.x + 100, r.y + 100); dialog.open(); }
private Shell getLimboShell() { if (limbo == null) { limbo = new Shell(Display.getCurrent(), SWT.NONE); // Place the limbo shell 'off screen' limbo.setLocation(0, 10000); limbo.setBackgroundMode(SWT.INHERIT_DEFAULT); limbo.setData(ShellActivationListener.DIALOG_IGNORE_KEY, Boolean.TRUE); } return limbo; }
protected Widget createUI(Display display) { Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setText("GeoMap Widget - SWT Native Map Browsing, Map data from openstreetmap.org"); shell.setSize(600, 710); shell.setLocation(10, 10); shell.setLayout(new FillLayout()); createControls(shell); shell.open(); return shell; }
/** * Centers a dialog (Shell) on the <b>primary</b> (active) display. * * @param shell Shell to center on screen * @see Shell */ public static void centerDialogOnScreen(Shell shell) { // do it by monitor to support dual-head cards and still center things correctly onto the screen // people are on. -- Emil Monitor m = Display.getDefault().getPrimaryMonitor(); Rectangle bounds = m.getBounds(); int screen_x = bounds.width; int screen_y = bounds.height; shell.setLocation( screen_x / 2 - (shell.getBounds().width / 2), screen_y / 2 - (shell.getBounds().height / 2)); }
protected Shell createSplash(Display display) { final Shell splash = new Shell(display, SWT.ON_TOP); splash.setLayout(new GridLayout(1, true)); Label l = new Label(splash, SWT.NONE); l.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); l.setText("Caleydo Sandbox"); splash.setSize(200, 100); Rectangle splashRect = splash.getBounds(); Rectangle displayRect = display.getBounds(); int x = (displayRect.width - splashRect.width) / 2; int y = (displayRect.height - splashRect.height) / 2; splash.setLocation(x, y); return splash; }
/** Open the window. */ public void open() { Display display = Display.getDefault(); createContents(); DisplayMonitor dm = new DisplayMonitor(shell, display); shell.setLocation(dm.getMonitorCenterXCoordinate(), dm.getMonitorCenterYCoordinate()); shell.open(); shell.layout(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
/** Show the window and return when it's closed. */ public void show() { Rectangle dispSize = display.getBounds(); shell.setLocation( (dispSize.width - shell.getSize().x) / 2, (dispSize.height - shell.getSize().y) / 2); shell.open(); // This is to force redraw -- at some point SWT stopped drawing // window contents correctly on start, but after resizing everything // looks fine. shell.setSize(shell.getSize().x + 1, shell.getSize().y + 1); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
public boolean open() { display = Display.getCurrent(); shell = new Shell(display, SWT.NO_TRIM | SWT.TOOL); // SWT.NO_TRIM | SWT.TOO shell.setLayout(new FillLayout()); int[] size = CPerspective.getSplashSize(); shell.setSize(size[0], size[1]); Composite composite = new Composite(shell, SWT.NONE); composite.setLayout(new FillLayout()); container = new FlashContainer(composite, "splash"); container.addHookInterceptor( new OleHookInterceptor() { public boolean intercept(Msg message, int code, int param, int param2) { if (message.getMessage() == Win32Constant.WM_RBUTTONDOWN) { Point cursor = container.getParent().toControl(Display.getCurrent().getCursorLocation()); if (container.getBounds().contains(cursor) && container.isVisible()) { return true; } } return false; } }); container.loadMovie(0, CPerspective.getSplashSwfPath()); 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; if (x < 0) x = 0; if (y < 0) y = 0; shell.setLocation(x, y); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return true; }
@Override protected void configureShell(Shell newShell) { super.configureShell(newShell); /* * Provide different resolutions for icons to get high quality rendering * wherever the OS needs large icons. For example, the ALT+TAB window on * certain systems uses a larger icon. */ newShell.setImages( new Image[] { Images.WINDOW_ICON_SMALL, Images.WINDOW_ICON_LARGE, Images.WINDOW_ICON_XLARGE, Images.WINDOW_ICON_XXLARGE }); newShell.setText(XdccBeeMessages.getString("Application_TITLE")); // $NON-NLS-1$ newShell.setSize(getSettings().getMainWindowSize()); if (getSettings().getMainWindowPosition().x != 0 || getSettings().getMainWindowPosition().y != 0) { newShell.setLocation(getSettings().getMainWindowPosition()); } else { centerShell(newShell); } newShell.addDisposeListener( new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { new ActionQuit(false).run(); } }); if (newShell.getDisplay().getSystemTray() != null && !isMac()) { // TODO: // Tray // for // mac?! // shellIconified // doesnt // work // under // mac newShell.addShellListener( new ShellAdapter() { public void shellIconified(ShellEvent e) { window.getShell().setVisible(false); } }); } }
public SWTApp(Display display) { shell = new Shell(display); shell.setText("Nibbles"); initUI(); shell.setSize(320, 335); shell.setLocation(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
/** Open the dialog */ public QueryOptionsPack open(QueryOptionsPack opt) { createContents(opt); shell.setLocation( getParent().getLocation().x + (getParent().getSize().x / 2) - (shell.getSize().x / 2), getParent().getLocation().y + (getParent().getSize().y / 2) - (shell.getSize().y / 2)); shell.open(); shell.layout(); Display display = getParent().getDisplay(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } return opt; }
public static void main(String[] args) throws Exception { Display display = new Display(); Shell shell = new Shell(display); shell.setText("GeoMap Widget - SWT Native Map Browsing, Map data from openstreetmap.org"); shell.setSize(600, 710); shell.setLocation(10, 10); shell.setLayout(new FillLayout()); new GeoMap(shell, SWT.NONE); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
public SWTApp(Display display) { shell = new Shell(display); shell.addPaintListener(new LyricsExamplePaintListener()); shell.setText("Soulmate"); shell.setSize(380, 300); shell.setLocation(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
private void track(MouseEvent e) { // Create and track the feedback overlay if (dragShell == null) createFeedback(); // Move the drag shell Rectangle b = dragItem.getBounds(); Point p = new Point(e.x, e.y); p = dragShell.getDisplay().map(dragItem.getParent(), null, p); dragShell.setLocation(p.x - (b.width / 2), p.y - (b.height / 2)); // Set the cursor feedback ToolBar bar = (ToolBar) e.widget; ToolItem curItem = bar.getItem(new Point(e.x, e.y)); if (curItem != null && curItem.getData() instanceof MPerspective) { psTB.setCursor(psTB.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); } else { psTB.setCursor(psTB.getDisplay().getSystemCursor(SWT.CURSOR_NO)); } }
/** * Opens the dialog and returns the input * * @return String */ public String open() { // Create the dialog window Shell shell = new Shell(getParent(), getStyle()); shell.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); shell.setText(getText()); shell.setSize(900, 400); Point location = getParent().getShell().getLocation(); Point size = getParent().getShell().getSize(); shell.setLocation((location.x + size.x - 300) / 2, (location.y + size.y - 150) / 2); createContents(shell); shell.open(); Display display = getParent().getDisplay(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return null; }