Codota Logo
Composite.getMonitor
Code IndexAdd Codota to your IDE (free)

How to use
getMonitor
method
in
org.eclipse.swt.widgets.Composite

Best Java code snippets using org.eclipse.swt.widgets.Composite.getMonitor (Showing top 17 results out of 315)

  • Common ways to obtain Composite
private void myMethod () {
Composite c =
  • Codota IconControl control;control.getParent()
  • Codota IconStatusDialog zuper;(Composite) zuper.createDialogArea(parent)
  • Codota IconTitleAreaDialog zuper;(Composite) zuper.createDialogArea(parent)
  • Smart code suggestions by Codota
}
origin: pentaho/pentaho-kettle

public static void setSize( Shell shell, int minWidth, int minHeight, boolean packIt ) {
 PropsUI props = PropsUI.getInstance();
 WindowProperty winprop = props.getScreen( shell.getText() );
 if ( winprop != null ) {
  winprop.setShell( shell, minWidth, minHeight );
 } else {
  if ( packIt ) {
   shell.pack();
  } else {
   shell.layout();
  }
  // OK, sometimes this produces dialogs that are waay too big.
  // Try to limit this a bit, m'kay?
  // Use the same algorithm by cheating :-)
  //
  winprop = new WindowProperty( shell );
  winprop.setShell( shell, minWidth, minHeight );
  // Now, as this is the first time it gets opened, try to put it in the middle of the screen...
  Rectangle shellBounds = shell.getBounds();
  Monitor monitor = shell.getDisplay().getPrimaryMonitor();
  if ( shell.getParent() != null ) {
   monitor = shell.getParent().getMonitor();
  }
  Rectangle monitorClientArea = monitor.getClientArea();
  int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2;
  int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2;
  shell.setLocation( middleX, middleY );
 }
}
origin: pentaho/pentaho-kettle

public static void setSize( Shell shell, int prefWidth, int prefHeight ) {
 PropsUI props = PropsUI.getInstance();
 WindowProperty winprop = props.getScreen( shell.getText() );
 if ( winprop != null ) {
  winprop.setShell( shell, prefWidth, prefHeight );
 } else {
  shell.layout();
  winprop = new WindowProperty( shell.getText(), false, new Rectangle( 0, 0, prefWidth, prefHeight ) );
  winprop.setShell( shell );
  // Now, as this is the first time it gets opened, try to put it in the middle of the screen...
  Rectangle shellBounds = shell.getBounds();
  Monitor monitor = shell.getDisplay().getPrimaryMonitor();
  if ( shell.getParent() != null ) {
   monitor = shell.getParent().getMonitor();
  }
  Rectangle monitorClientArea = monitor.getClientArea();
  int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2;
  int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2;
  shell.setLocation( middleX, middleY );
 }
}
origin: pentaho/pentaho-kettle

Monitor monitor = shell.getDisplay().getPrimaryMonitor();
if ( shell.getParent() != null ) {
 monitor = shell.getParent().getMonitor();
origin: pentaho/pentaho-kettle

Monitor monitor = shell.getDisplay().getPrimaryMonitor();
if ( shell.getParent() != null ) {
 monitor = shell.getParent().getMonitor();
origin: openaudible/openaudible

public void updateFakeTooltip(String tooltip, Composite c) {
  Rectangle rect = c.getMonitor().getBounds();
  updateFakeTooltip(tooltip, rect, false);
}

origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

void center () {
  if (parent == null) return;
  Rectangle rect = getBoundsInPixels ();
  Rectangle parentRect = display.mapInPixels (parent, null, parent.getClientAreaInPixels());
  int x = Math.max (parentRect.x, parentRect.x + (parentRect.width - rect.width) / 2);
  int y = Math.max (parentRect.y, parentRect.y + (parentRect.height - rect.height) / 2);
  Rectangle monitorRect = parent.getMonitor ().getClientArea();
  if (x + rect.width > monitorRect.x + monitorRect.width) {
    x = Math.max (monitorRect.x, monitorRect.x + monitorRect.width - rect.width);
  } else {
    x = Math.max (x, monitorRect.x);
  }
  if (y + rect.height > monitorRect.y + monitorRect.height) {
    y = Math.max (monitorRect.y, monitorRect.y + monitorRect.height - rect.height);
  } else {
    y = Math.max (y, monitorRect.y);
  }
  setLocationInPixels (x, y);
}

origin: org.eclipse.swt.cocoa.macosx/x86_64

void center () {
  if (parent == null) return;
  Rectangle rect = getBounds ();
  Rectangle parentRect = display.map (parent, null, parent.getClientArea());
  int x = Math.max (parentRect.x, parentRect.x + (parentRect.width - rect.width) / 2);
  int y = Math.max (parentRect.y, parentRect.y + (parentRect.height - rect.height) / 2);
  Rectangle monitorRect = parent.getMonitor ().getClientArea();
  if (x + rect.width > monitorRect.x + monitorRect.width) {
    x = Math.max (monitorRect.x, monitorRect.x + monitorRect.width - rect.width);
  } else {
    x = Math.max (x, monitorRect.x);
  }
  if (y + rect.height > monitorRect.y + monitorRect.height) {
    y = Math.max (monitorRect.y, monitorRect.y + monitorRect.height - rect.height);
  } else {
    y = Math.max (y, monitorRect.y);
  }
  setLocation (x, y);
}

origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

@Override
protected Point getInitialLocation(Point initialSize) {
  Composite parent = getShell().getParent();
  if (!centerOnMonitor || parent == null) {
    return super.getInitialLocation(initialSize);
  }
  Monitor monitor = parent.getMonitor();
  Rectangle monitorBounds = monitor.getClientArea();
  Point centerPoint = Geometry.centerPoint(monitorBounds);
  return new Point(centerPoint.x - (initialSize.x / 2), Math.max(
      monitorBounds.y, Math.min(centerPoint.y
          - (initialSize.y * 2 / 3), monitorBounds.y
          + monitorBounds.height - initialSize.y)));
}
origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

void center () {
  if (parent == null) return;
  Rectangle rect = getBoundsInPixels ();
  Rectangle parentRect = display.mapInPixels (parent, null, parent.getClientAreaInPixels());
  int x = Math.max (parentRect.x, parentRect.x + (parentRect.width - rect.width) / 2);
  int y = Math.max (parentRect.y, parentRect.y + (parentRect.height - rect.height) / 2);
  Rectangle monitorRect = DPIUtil.autoScaleUp(parent.getMonitor ().getClientArea());
  if (x + rect.width > monitorRect.x + monitorRect.width) {
    x = Math.max (monitorRect.x, monitorRect.x + monitorRect.width - rect.width);
  } else {
    x = Math.max (x, monitorRect.x);
  }
  if (y + rect.height > monitorRect.y + monitorRect.height) {
    y = Math.max (monitorRect.y, monitorRect.y + monitorRect.height - rect.height);
  } else {
    y = Math.max (y, monitorRect.y);
  }
  setLocationInPixels (x, y);
}

origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x

void center () {
  if (parent == null) return;
  Rectangle rect = getBoundsInPixels ();
  Rectangle parentRect = display.mapInPixels (parent, null, parent.getClientAreaInPixels());
  int x = Math.max (parentRect.x, parentRect.x + (parentRect.width - rect.width) / 2);
  int y = Math.max (parentRect.y, parentRect.y + (parentRect.height - rect.height) / 2);
  Rectangle monitorRect = DPIUtil.autoScaleUp(parent.getMonitor ().getClientArea());
  if (x + rect.width > monitorRect.x + monitorRect.width) {
    x = Math.max (monitorRect.x, monitorRect.x + monitorRect.width - rect.width);
  } else {
    x = Math.max (x, monitorRect.x);
  }
  if (y + rect.height > monitorRect.y + monitorRect.height) {
    y = Math.max (monitorRect.y, monitorRect.y + monitorRect.height - rect.height);
  } else {
    y = Math.max (y, monitorRect.y);
  }
  setLocationInPixels (x, y);
}

origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

void center () {
  if (parent == null) return;
  Rectangle rect = getBoundsInPixels ();
  Rectangle parentRect = display.mapInPixels (parent, null, parent.getClientAreaInPixels());
  int x = Math.max (parentRect.x, parentRect.x + (parentRect.width - rect.width) / 2);
  int y = Math.max (parentRect.y, parentRect.y + (parentRect.height - rect.height) / 2);
  Rectangle monitorRect = DPIUtil.autoScaleUp(parent.getMonitor ().getClientArea());
  if (x + rect.width > monitorRect.x + monitorRect.width) {
    x = Math.max (monitorRect.x, monitorRect.x + monitorRect.width - rect.width);
  } else {
    x = Math.max (x, monitorRect.x);
  }
  if (y + rect.height > monitorRect.y + monitorRect.height) {
    y = Math.max (monitorRect.y, monitorRect.y + monitorRect.height - rect.height);
  } else {
    y = Math.max (y, monitorRect.y);
  }
  setLocationInPixels (x, y);
}

origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

/**
 * Returns the initial location to use for the shell. The default
 * implementation centers the shell horizontally (1/2 of the difference to
 * the left and 1/2 to the right) and vertically (1/3 above and 2/3 below)
 * relative to the parent shell, or display bounds if there is no parent
 * shell.
 *
 * @param initialSize
 *            the initial size of the shell, as returned by
 *            <code>getInitialSize</code>.
 * @return the initial location of the shell
 */
protected Point getInitialLocation(Point initialSize) {
  Composite parent = shell.getParent();
  Monitor monitor = shell.getDisplay().getPrimaryMonitor();
  if (parent != null) {
    monitor = parent.getMonitor();
  }
  Rectangle monitorBounds = monitor.getClientArea();
  Point centerPoint;
  if (parent != null) {
    centerPoint = Geometry.centerPoint(parent.getBounds());
  } else {
    centerPoint = Geometry.centerPoint(monitorBounds);
  }
  return new Point(centerPoint.x - (initialSize.x / 2), Math.max(
      monitorBounds.y, Math.min(centerPoint.y
          - (initialSize.y * 2 / 3), monitorBounds.y
          + monitorBounds.height - initialSize.y)));
}
origin: org.eclipse.rap/org.eclipse.rap.jface

/**
 * Returns the initial location to use for the shell. The default
 * implementation centers the shell horizontally (1/2 of the difference to
 * the left and 1/2 to the right) and vertically (1/3 above and 2/3 below)
 * relative to the parent shell, or display bounds if there is no parent
 * shell.
 * 
 * @param initialSize
 *            the initial size of the shell, as returned by
 *            <code>getInitialSize</code>.
 * @return the initial location of the shell
 */
protected Point getInitialLocation(Point initialSize) {
  Composite parent = shell.getParent();
  Monitor monitor = shell.getDisplay().getPrimaryMonitor();
  if (parent != null) {
    monitor = parent.getMonitor();
  }
  Rectangle monitorBounds = monitor.getClientArea();
  Point centerPoint;
  if (parent != null) {
    centerPoint = Geometry.centerPoint(parent.getBounds());
  } else {
    centerPoint = Geometry.centerPoint(monitorBounds);
  }
  return new Point(centerPoint.x - (initialSize.x / 2), Math.max(
      monitorBounds.y, Math.min(centerPoint.y
          - (initialSize.y * 2 / 3), monitorBounds.y
          + monitorBounds.height - initialSize.y)));
}
origin: org.eclipse.platform/org.eclipse.jface

/**
 * Returns the initial location to use for the shell. The default
 * implementation centers the shell horizontally (1/2 of the difference to
 * the left and 1/2 to the right) and vertically (1/3 above and 2/3 below)
 * relative to the parent shell, or display bounds if there is no parent
 * shell.
 *
 * @param initialSize
 *            the initial size of the shell, as returned by
 *            <code>getInitialSize</code>.
 * @return the initial location of the shell
 */
protected Point getInitialLocation(Point initialSize) {
  Composite parent = shell.getParent();
  Monitor monitor = shell.getDisplay().getPrimaryMonitor();
  if (parent != null) {
    monitor = parent.getMonitor();
  }
  Rectangle monitorBounds = monitor.getClientArea();
  Point centerPoint;
  if (parent != null) {
    centerPoint = Geometry.centerPoint(parent.getBounds());
  } else {
    centerPoint = Geometry.centerPoint(monitorBounds);
  }
  return new Point(centerPoint.x - (initialSize.x / 2), Math.max(
      monitorBounds.y, Math.min(centerPoint.y
          - (initialSize.y * 2 / 3), monitorBounds.y
          + monitorBounds.height - initialSize.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.platform/org.eclipse.swt.examples

/**
 * Creates an instance of a ControlExample embedded inside
 * the supplied parent Composite.
 *
 * @param parent the container of the example
 */
public ControlExample(Composite parent) {
  initResources();
  tabFolder = new TabFolder (parent, SWT.NONE);
  tabs = createTabs();
  for (Tab tab : tabs) {
    TabItem item = new TabItem (tabFolder, SWT.NONE);
    item.setText (tab.getTabText ());
    item.setControl (tab.createTabFolderPage (tabFolder));
    item.setData (tab);
  }
  /* Workaround: if the tab folder is wider than the screen,
   * Mac platforms clip instead of somehow scrolling the tab items.
   * We try to recover some width by using shorter tab names. */
  Point size = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
  Rectangle monitorArea = parent.getMonitor().getClientArea();
  boolean isMac = SWT.getPlatform().equals("cocoa");
  if (size.x > monitorArea.width && isMac) {
    TabItem [] tabItems = tabFolder.getItems();
    for (int i=0; i<tabItems.length; i++) {
      tabItems[i].setText (tabs [i].getShortTabText ());
    }
  }
  startup = false;
}
origin: BiglySoftware/BiglyBT

Rectangle displayRect;
try {
  displayRect = composite.getMonitor().getClientArea();
} catch (NoSuchMethodError e) {
  displayRect = composite.getDisplay().getClientArea();
org.eclipse.swt.widgetsCompositegetMonitor

Popular methods of Composite

  • setLayout
    Sets the layout which is associated with the receiver to be the argument which may be null.
  • <init>
    Constructs a new instance of this class given its parent and a style value describing its behavior a
  • setLayoutData
  • layout
    Forces a lay out (that is, sets the size and location) of all widgets that are in the parent hierarc
  • getDisplay
  • getChildren
    Returns a (possibly empty) array containing the receiver's children. Children are returned in the or
  • getShell
  • getFont
  • getLayout
    Returns layout which is associated with the receiver, or null if one has not been set.
  • setFont
  • getParent
  • computeSize
  • getParent,
  • computeSize,
  • dispose,
  • setBackground,
  • getClientArea,
  • isDisposed,
  • getBackground,
  • setVisible,
  • setSize,
  • setData

Popular in Java

  • Finding current android device location
  • addToBackStack (FragmentTransaction)
  • setContentView (Activity)
  • setScale (BigDecimal)
    Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to thi
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now