congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Window.getGraphicsConfiguration
Code IndexAdd Tabnine to your IDE (free)

How to use
getGraphicsConfiguration
method
in
java.awt.Window

Best Java code snippets using java.awt.Window.getGraphicsConfiguration (Showing top 20 results out of 387)

origin: chewiebug/GCViewer

public Dimension getPreferredSize() {
  Dimension size = super.getPreferredSize();
  
  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  Insets scnMax = Toolkit.getDefaultToolkit().getScreenInsets(getOwner().getGraphicsConfiguration());
  int taskBarSize = scnMax.bottom;
  
  int usableScreenHeight = screenSize.height - taskBarSize - 50;
  
  if (size.height > (usableScreenHeight)) {
    size.height = usableScreenHeight;
  }
  
  return size;
}
origin: org.netbeans.api/org-openide-util

/**
 * Finds out the monitor where the user currently has the input focus.
 * This method is usually used to help the client code to figure out on
 * which monitor it should place newly created windows/frames/dialogs.
 *
 * @return the GraphicsConfiguration of the monitor which currently has the
 * input focus
 */
private static GraphicsConfiguration getCurrentGraphicsConfiguration() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  if (focusOwner != null) {
    Window w = SwingUtilities.getWindowAncestor(focusOwner);
    if (w != null) {
      return w.getGraphicsConfiguration();
    } else {
      //#217737 - try to find the main window which could be placed in secondary screen
      for( Frame f : Frame.getFrames() ) {
        if( "NbMainWindow".equals(f.getName())) { //NOI18N
          return f.getGraphicsConfiguration();
        }
      }
    }
  }
  return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
}
origin: org.netbeans.api/org-openide-util-ui

/**
 * Finds out the monitor where the user currently has the input focus.
 * This method is usually used to help the client code to figure out on
 * which monitor it should place newly created windows/frames/dialogs.
 *
 * @return the GraphicsConfiguration of the monitor which currently has the
 * input focus
 */
private static GraphicsConfiguration getCurrentGraphicsConfiguration() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  if (focusOwner != null) {
    Window w = SwingUtilities.getWindowAncestor(focusOwner);
    if (w != null) {
      return w.getGraphicsConfiguration();
    } else {
      //#217737 - try to find the main window which could be placed in secondary screen
      for( Frame f : Frame.getFrames() ) {
        if( "NbMainWindow".equals(f.getName())) { //NOI18N
          return f.getGraphicsConfiguration();
        }
      }
    }
  }
  return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
}
origin: stackoverflow.com

w.setBounds(w.getGraphicsConfiguration().getBounds());
w.setVisible(true);
origin: stackoverflow.com

 Window w=new Window(null)
{
 @Override
 public void paint(Graphics g)
 {
  final Font font = getFont().deriveFont(48f);
  g.setFont(font);
  g.setColor(Color.RED);
  final String message = "Hello";
  FontMetrics metrics = g.getFontMetrics();
  g.drawString(message,
   (getWidth()-metrics.stringWidth(message))/2,
   (getHeight()-metrics.getHeight())/2);
 }
 @Override
 public void update(Graphics g)
 {
  paint(g);
 }
};
w.setAlwaysOnTop(true);
w.setBounds(w.getGraphicsConfiguration().getBounds());
w.setBackground(new Color(0, true));
w.setVisible(true);
origin: stackoverflow.com

 public GraphicsDevice getMonitorWindowIsOn(Window window)
{
  // First, grab the x,y position of the Window object
  GraphicsConfiguration windowGraphicsConfig = window.getGraphicsConfiguration();
  if (windowGraphicsConfig == null)
  {
     return null; // Should probably be handled better
  }
  Rectangle windowBounds = windowGraphicsConfig.getBounds();

  for (GraphicsDevice gd : ge.getScreenDevices()) {
    Rectangle monitorBounds = gd.getDefaultConfiguration().getBounds();
    if (monitorBounds.contains(windowBounds.x, windowBounds.y))
    {
      return gd;
    }
  }
  // um, return null I guess, should make this default better though,
  // maybe to the default screen device, except, I am sure if no monitors are
  // connected that may be null as well.
  return null;
}
origin: com.github.lgooddatepicker/LGoodDatePicker

/**
 * getScreenTotalArea, This returns the total area of the screen. (The total area includes any
 * task bars.) This function accounts for multi-monitor setups. If a window is supplied, then
 * the the monitor that contains the window will be used. If a window is not supplied, then the
 * primary monitor will be used.
 */
static public Rectangle getScreenTotalArea(Window windowOrNull) {
  Rectangle bounds;
  if (windowOrNull == null) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    bounds = ge.getDefaultScreenDevice().getDefaultConfiguration().getBounds();
  } else {
    GraphicsConfiguration gc = windowOrNull.getGraphicsConfiguration();
    bounds = gc.getBounds();
  }
  return bounds;
}
origin: mucommander/mucommander

/**
 * Computes the screen's insets for the specified window and returns them.
 * <p>
 * While this might seem strange, screen insets can change from one window
 * to another. For example, on X11 windowing systems, there is no guarantee that
 * a window will be displayed on the same screen, let alone computer, as the one
 * the application is running on.
 * </p>
 * @param window the window for which screen insets should be computed.
 * @return the screen's insets for the specified window
 */
public static Insets getScreenInsets(Window window) {
  return Toolkit.getDefaultToolkit().getScreenInsets(window.getGraphicsConfiguration());
}

origin: mucommander/mucommander

/**
 * Computes the screen's insets for the specified window and returns them.
 * <p>
 * While this might seem strange, screen insets can change from one window
 * to another. For example, on X11 windowing systems, there is no guarantee that
 * a window will be displayed on the same screen, let alone computer, as the one
 * the application is running on.
 * </p>
 * @param window the window for which screen insets should be computed.
 * @return the screen's insets for the specified window
 */
public static Insets getScreenInsets(Window window) {
  return Toolkit.getDefaultToolkit().getScreenInsets(window.getGraphicsConfiguration());
}

origin: mucommander/mucommander

  /**
   * Returns the maximum dimensions for a full-screen window.
   *
   * @param window window who's full screen size should be computed.
   * @return the maximum dimensions for a full-screen window
   */
  public static Rectangle getFullScreenBounds(Window window) {
    Toolkit   toolkit;
    Dimension screenSize;

    toolkit    = Toolkit.getDefaultToolkit();
    screenSize = toolkit.getScreenSize();

    Insets screenInsets = toolkit.getScreenInsets(window.getGraphicsConfiguration());
    return new Rectangle(screenInsets.left, screenInsets.top, screenSize.width-screenInsets.left-screenInsets.right, screenSize.height-screenInsets.top-screenInsets.bottom);
  }
}
origin: org.jdesktop.bsaf/bsaf

/**
 * Calculates default location for the specified window.
 * @return default location for the window
 * @param window the window location is calculated for.
 *               It should not be null.
 */
public static Point defaultLocation(Window window) {
  GraphicsConfiguration gc = window.getGraphicsConfiguration();
  Rectangle bounds = gc.getBounds();
  Insets insets = window.getToolkit().getScreenInsets(gc);
  int x = bounds.x + insets.left;
  int y = bounds.y + insets.top;
  return new Point(x, y);
}
origin: stackoverflow.com

static public Insets getScreenInsets(Window wnd) {
 Insets                              si;
 try {
   if(wnd==null) { si=Toolkit.getDefaultToolkit().getScreenInsets(new Frame().getGraphicsConfiguration()); }
   else          { si=wnd.getToolkit()           .getScreenInsets(wnd.getGraphicsConfiguration());         }
   } catch(NoSuchMethodError thr) { si=new Insets(0,0,0,0); }
 return si;
 }
origin: org.bitbucket.goalhub.simpleide/jedit

private static Point fitInScreen(Point p, Window w, int lineHeight)
{
  Rectangle screenSize = w.getGraphicsConfiguration().getBounds();
  if(p.y + w.getHeight() >= screenSize.height)
    p.y = p.y - w.getHeight() - lineHeight;
  return p;
} //}}}
origin: org.codehaus.jtstand/jtstand-desktop

private static Rectangle getUsableDeviceBounds(Window window) {
  Window owner = window.getOwner();
  GraphicsConfiguration gc = null;
  
  if (owner == null) {
    gc = GraphicsEnvironment.getLocalGraphicsEnvironment()
        .getDefaultScreenDevice().getDefaultConfiguration();
  } else {
    gc = owner.getGraphicsConfiguration();
  }
  
  Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
  Rectangle bounds = gc.getBounds();
  bounds.x += insets.left;
  bounds.y += insets.top;
  bounds.width -= (insets.left + insets.right);
  bounds.height -= (insets.top + insets.bottom);
  
  return bounds;
}
 
origin: in.jlibs/org-openide-util

/**
 * Finds out the monitor where the user currently has the input focus.
 * This method is usually used to help the client code to figure out on
 * which monitor it should place newly created windows/frames/dialogs.
 *
 * @return the GraphicsConfiguration of the monitor which currently has the
 * input focus
 */
private static GraphicsConfiguration getCurrentGraphicsConfiguration() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  if (focusOwner != null) {
    Window w = SwingUtilities.getWindowAncestor(focusOwner);
    if (w != null) {
      return w.getGraphicsConfiguration();
    }
  }
  return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
}
origin: org.bitbucket.goalhub.simpleide/jedit

private static Point fitInScreen(Point p, Window w, int lineHeight)
{
  Rectangle screenSize = w.getGraphicsConfiguration().getBounds();
  if(p.y + w.getHeight() >= screenSize.height)
    p.y = p.y - w.getHeight() - lineHeight;
  return p;
} //}}}
origin: org.gosu-lang.gosu/gosu-editor

public static void ensureWindowIsVisible( Window w )
{
 int width = w.getWidth();
 int height = w.getHeight();
 Toolkit toolkit = Toolkit.getDefaultToolkit();
 GraphicsConfiguration gc = w.getGraphicsConfiguration();
 Insets screenInsets = toolkit.getScreenInsets( gc );
 Rectangle screenSize = gc.getBounds();
 w.setLocation( Math.max( screenInsets.left, Math.min( w.getX(), screenSize.width - screenInsets.right - width ) ),
         Math.max( screenInsets.top, Math.min( w.getY(), screenSize.height - screenInsets.bottom - height ) ) );
}
origin: net.sourceforge.mydoggy/mydoggy-plaf

public static void restoreFullScreenWindow(Window window) {
  Rectangle bounds = fullScreenBounds.remove(window);
  if (bounds != null) {
    window.setBounds(bounds);
  } else {
    GraphicsDevice graphicsDevice = window.getGraphicsConfiguration().getDevice();
    if (graphicsDevice.isFullScreenSupported())
      graphicsDevice.setFullScreenWindow(null);
  }
}
origin: otros-systems/otroslogviewer

public static void centerOnScreen(Window target) {
 DisplayMode displayMode = target.getGraphicsConfiguration().getDevice().getDisplayMode();
 int displayHeight = displayMode.getHeight();
 int displayWidth = displayMode.getWidth();
 Dimension targetSize = target.getSize();
 Point frameLocation = new Point(displayWidth / 2 - targetSize.width / 2, displayHeight / 2 - targetSize.height / 2);
 target.setLocation(frameLocation);
}
origin: net.anwiba.commons/anwiba-commons-swing-core

public static void centerToScreen(final Window window) {
 if (window == null) {
  return;
 }
 final DisplayMode displayMode = window.getGraphicsConfiguration().getDevice().getDisplayMode();
 final Point location = getCenterToScreenLocation(displayMode, window.getSize());
 window.setLocation(location);
 return;
}
java.awtWindowgetGraphicsConfiguration

Javadoc

This method returns the GraphicsConfiguration used by this Window.

Popular methods of Window

  • dispose
    Releases all of the native screen resources used by thisWindow, its subcomponents, and all of its ow
  • setVisible
  • setLocation
  • pack
    Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. If the wi
  • addWindowListener
    Adds the specified window listener to receive window events from this window. If l is null, no excep
  • getSize
  • getWidth
  • getHeight
  • setSize
  • setBounds
  • getBounds
  • removeWindowListener
    Removes the specified window listener so that it no longer receives window events from this window.
  • getBounds,
  • removeWindowListener,
  • isVisible,
  • addComponentListener,
  • getX,
  • getY,
  • toFront,
  • getLocation,
  • removeComponentListener

Popular in Java

  • Making http post requests using okhttp
  • getResourceAsStream (ClassLoader)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • addToBackStack (FragmentTransaction)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Top Vim plugins
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