Tabnine Logo
Display.getPrimaryMonitor
Code IndexAdd Tabnine to your IDE (free)

How to use
getPrimaryMonitor
method
in
org.eclipse.swt.widgets.Display

Best Java code snippets using org.eclipse.swt.widgets.Display.getPrimaryMonitor (Showing top 20 results out of 315)

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

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: 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

final Display display = getShell().getDisplay();  
 final Monitor monitor = display.getPrimaryMonitor();
 final Rectangle rect;
 if (monitor != null) {
  rect = monitor.getClientArea();
 } else {
  // In case we cannot find the primary monitor get the entire display rectangle
  // Note that it may include the dimensions of multiple monitors. 
  rect = display.getBounds();
 }
 System.out.println("Monitor width=" + String.valueOf(rect.width));
 System.out.println("Monitor height=" + String.valueOf(rect.height));
origin: org.eclipse.rap/org.eclipse.rap.rwt

/**
 * Returns the receiver's monitor.
 *
 * @return the receiver's monitor
 *
 * @since 1.2
 */
public Monitor getMonitor() {
 checkWidget();
 return display.getPrimaryMonitor();
}
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: com.github.rinde/rinsim-example

/**
 * Starts the example.
 * @param args One optional argument specifying the simulation end time is
 *          supported.
 */
public static void main(@Nullable String[] args) {
 final long endTime = args != null && args.length >= 1 ? Long
  .parseLong(args[0]) : Long.MAX_VALUE;
 final Display d = new Display();
 @Nullable
 Monitor sec = null;
 for (final Monitor m : d.getMonitors()) {
  if (d.getPrimaryMonitor() != m) {
   sec = m;
   break;
  }
 }
 run(endTime, d, sec, null);
}
origin: rinde/RinSim

/**
 * Starts the example.
 * @param args One optional argument specifying the simulation end time is
 *          supported.
 */
public static void main(@Nullable String[] args) {
 final long endTime = args != null && args.length >= 1 ? Long
  .parseLong(args[0]) : Long.MAX_VALUE;
 final Display d = new Display();
 @Nullable
 Monitor sec = null;
 for (final Monitor m : d.getMonitors()) {
  if (d.getPrimaryMonitor() != m) {
   sec = m;
   break;
  }
 }
 run(endTime, d, sec, null);
}
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/xmartserver

/**
 * 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.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: stackoverflow.com

 public static String openNewShellDialog(Display display)
{
  final Shell shell = new Shell(display , SWT.APPLICATION_MODAL); 
  shell.setLayout(new GridLayout(1, false));
  System.out.println(display.getPrimaryMonitor().getClientArea());
  shell.setLocation(616, 500); //It seems the location is relative to the center of the Shell w.r.t client area
  shell.setSize(0,0);
  shell.setVisible(false);
  shell.open();

  FileDialog d = new FileDialog(shell);
  String s = d.open();

  shell.dispose (); 
  while (!shell.isDisposed ()) { 
    if (!display.readAndDispatch ()) display.sleep (); 
  } 

  return s;
}
origin: stackoverflow.com

 public static void main(String[] args)
{
  Display display = new Display();
  final Shell shell = new Shell(display);
  shell.setLayout(new FillLayout(SWT.VERTICAL));
  shell.setText("StackOverflow");

  Monitor primary = display.getPrimaryMonitor();

    /* Get the available screen size (without start menu) */
  Rectangle area = primary.getClientArea();

  shell.pack();
  /* Set the shell size */
  shell.setBounds(area.x + area.width / 2, area.y, area.width / 2, area.height);
  shell.open();
  while (!shell.isDisposed())
  {
    if (!display.readAndDispatch())
      display.sleep();
  }
  display.dispose();
}
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;
    }
  }
}

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

void updateSystemUIMode () {
  if ((window.collectionBehavior() & OS.NSWindowCollectionBehaviorFullScreenPrimary) != 0) return;
  if (!getMonitor ().equals (display.getPrimaryMonitor ())) return;
  int mode = display.systemUIMode, options = display.systemUIOptions;
  if (fullScreen) {
    mode = OS.kUIModeAllHidden;
    if (menuBar != null) {
      mode = OS.kUIModeContentHidden;
    }
    options = 0;
  }
  int[] uiMode = new int[1], uiOptions = new int[1];
  OS.GetSystemUIMode(uiMode, uiOptions);
  if (uiMode[0] != mode || uiOptions[0] != options) OS.SetSystemUIMode (mode, options);
  if (fullScreen)	window.setFrame(fullScreenFrame, true);
}

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);
}
org.eclipse.swt.widgetsDisplaygetPrimaryMonitor

Javadoc

Returns the primary monitor for that device.

Popular methods of Display

  • asyncExec
    Causes the run() method of the runnable to be invoked by the user-interface thread at the next reaso
  • getCurrent
    Returns the display which the currently running thread is the user-interface thread for, or null if
  • getDefault
    Returns the default display. One is created (making the thread that invokes this method its user-int
  • getSystemColor
    Returns the matching standard color for the given constant, which should be one of the color constan
  • readAndDispatch
    Reads an event from the operating system's event queue, dispatches it appropriately, and returns tru
  • syncExec
    Causes the run() method of the runnable to be invoked by the user-interface thread at the next reaso
  • sleep
    Causes the user-interface thread to sleep (that is, to be put in a state where it does not consume C
  • getActiveShell
    Returns the currently active Shell, or null if no shell belonging to the currently running applicati
  • isDisposed
  • timerExec
    Causes the run() method of the runnable to be invoked by the user-interface thread after the specifi
  • getThread
    Returns the user-interface thread for the receiver.
  • getFocusControl
    Returns the control which currently has keyboard focus, or null if keyboard events are not currently
  • getThread,
  • getFocusControl,
  • dispose,
  • getSystemCursor,
  • getSystemImage,
  • <init>,
  • getBounds,
  • getCursorLocation,
  • addFilter,
  • beep

Popular in Java

  • Updating database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • getContentResolver (Context)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now