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

How to use
getBounds
method
in
java.awt.Window

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

origin: org.netbeans.api/org-openide-awt

private static boolean willPopupBeContained(JPopupMenu popup, Point origin) {
  if (!popup.isShowing()) {
    return false;
  }
  Window w = SwingUtilities.windowForComponent(popup.getInvoker());
  Rectangle r = new Rectangle(origin, popup.getSize());
  return (w != null) && w.getBounds().contains(r);
}
origin: org.netbeans.api/org-openide-dialogs

/** Tries to resize wizard wisely if needed. Keeps "display inertia" so that
 * wizard is only enlarged, not shrinked, and location is changed only when
 * wizard window exceeds screen bounds after resize.
 */
private void resizeWizard(Window parentWindow, Dimension prevSize) {
  assert SwingUtilities.isEventDispatchThread () : "getComponent() must be called in EQ only.";
  Dimension curSize = data.getIterator(this).current().getComponent().getPreferredSize();
  // only enlarge if needed, don't shrink
  if ((curSize.width > prevSize.width) || (curSize.height > prevSize.height)) {
    Rectangle origBounds = parentWindow.getBounds();
    int newWidth = Math.max(origBounds.width + (curSize.width - prevSize.width), origBounds.width);
    int newHeight = Math.max(origBounds.height + (curSize.height - prevSize.height), origBounds.height);
    Rectangle screenBounds = Utilities.getUsableScreenBounds();
    Rectangle newBounds;
    // don't allow to exceed screen size, center if needed
    if (((origBounds.x + newWidth) > screenBounds.width) || ((origBounds.y + newHeight) > screenBounds.height)) {
      newWidth = Math.min(screenBounds.width, newWidth);
      newHeight = Math.min(screenBounds.height, newHeight);
      newBounds = Utilities.findCenterBounds(new Dimension(newWidth, newHeight));
    } else {
      newBounds = new Rectangle(origBounds.x, origBounds.y, newWidth, newHeight);
    }
    parentWindow.setBounds(newBounds);
    parentWindow.invalidate();
    parentWindow.validate();
    parentWindow.repaint();
  }
}
origin: com.fifesoft.rtext/fife.common

private boolean getShouldPaintGrip() {
  Rectangle rect = window.getBounds();
  Dimension dim = getToolkit().getScreenSize();
  if((rect.x == rect.y) && (rect.x <= 0) &&
    (rect.x>-20) && (dim.width-20<rect.width) &&
    (dim.width +20 > rect.width))
      return false;
  return true;
}
origin: net.java.dev.jna/jna-platform

  @Override
  public Rectangle getBounds() {
    return getOwner().getBounds();
  }
}
origin: stackoverflow.com

 button.addActionListener( new ActionListener()
{
  public void actionPerformed(ActionEvent e)
  {
    JButton button = (JButton)e.getSource();
    Window window = SwingUtilities.windowForComponent(button);
    JDialog dialog = new JDialog();
    dialog.setBounds( window.getBounds() );
    dialog.setVisible(true);
  }
});
origin: net.java.dev.jna/platform

  public Rectangle getBounds() {
    return getOwner().getBounds();
  }
}
origin: cmu-phil/tetrad

/**
 * Sets the location of the window to the middle of the screen
 *
 * @param window - component whos location is set.
 */
private static void setLocation(Window window) {
  Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
  Rectangle bounds = window.getBounds();
  window.setLocation((screenDim.width - bounds.width) / 2,
      (screenDim.height - bounds.height) / 2);
}
origin: org.scijava/scijava-ui-awt

/** Centers the given window within the specified parent window. */
public static void centerWindow(final Window parent, final Window window) {
  centerWindow(parent.getBounds(), window);
}
origin: com.l2fprod.common/l2fprod-common-shared

 private void store(Window w) {
  String bounds =
   (String)ConverterRegistry.instance().convert(
    String.class,
    w.getBounds());
  node().node("Windows").put(w.getName() + ".bounds", bounds);
 }
};
origin: openpreserve/jhove

/**
 *  Center the window at the top of the main screen.
 */
public static void centerTopWindow (Window win)
{
  Rectangle devBounds = mainBounds ();
  Rectangle winBounds = win.getBounds ();
  int lmargin = (devBounds.width - winBounds.width) / 2;
  // Don't go off the edge
  if (lmargin < 0) {
    lmargin = 0;
  }
  win.setLocation (lmargin, 0);
}

origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

private static boolean willPopupBeContained(JPopupMenu popup, Point origin) {
  if (!popup.isShowing()) {
    return false;
  }
  Window w = SwingUtilities.windowForComponent (popup.getInvoker());
  Rectangle r = new Rectangle (origin, popup.getSize ());
  return w != null && w.getBounds ().contains (r);
}
origin: openpreserve/jhove

/**
 *  Center the window on the main screen.
 */
public static void centerWindow (Window win)
{
  Rectangle devBounds = mainBounds ();
  Rectangle winBounds = win.getBounds ();
  int lmargin = (devBounds.width - winBounds.width) / 2;
  int tmargin = (devBounds.height - winBounds.height) / 2;
  // Don't go off the edge
  if (lmargin < 0) {
    lmargin = 0;
  }
  if (tmargin < 0) {
    tmargin = 0;
  }
  win.setLocation (lmargin, tmargin);
}
origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

private static boolean willPopupBeContained(JPopupMenu popup, Point origin) {
  if (!popup.isShowing()) {
    return false;
  }
  Window w = SwingUtilities.windowForComponent (popup.getInvoker());
  Rectangle r = new Rectangle (origin, popup.getSize ());
  return w != null && w.getBounds ().contains (r);
}
origin: org.bitbucket.goalhub.simpleide/jedit

@Override
public void componentMoved(ComponentEvent evt)
{
  if(System.currentTimeMillis() - start < 1000L)
  {
    Rectangle r = win.getBounds();
    if(!windowOpened && r.equals(required))
      return;
    if(!r.equals(desired))
    {
      Log.log(Log.DEBUG,GUIUtilities.class,
        "Window resize blocked: " + win.getBounds());
      win.setBounds(desired);
    }
  }
  win.removeComponentListener(this);
} //}}}
origin: senbox-org/snap-desktop

  @Override
  public void actionPerformed(ActionEvent e) {
    LayerSourceAssistantPane pane = new LayerSourceAssistantPane(SwingUtilities.getWindowAncestor(control),
                                   "Add Layer");
    final Map<String, LayerSourceDescriptor> layerSourceDescriptors1 =
        LayerManager.getDefault().getLayerSourceDescriptors();
    final LayerSourceDescriptor[] layerSourceDescriptors2 =
        layerSourceDescriptors1.values().toArray(new LayerSourceDescriptor[layerSourceDescriptors1.size()]);
    pane.show(new SelectLayerSourceAssistantPage(layerSourceDescriptors2), screenBounds);
    screenBounds = pane.getWindow().getBounds();
  }
}
origin: groboclown/p4ic4idea

public static void show(@NotNull Project project, @NotNull List<ServerConfig> configs,
    @NotNull ChooseListener listener) {
  ChooseLabelDialog dialog = new ChooseLabelDialog(project, configs, listener);
  dialog.pack();
  final Dimension bounds = dialog.getSize();
  final Rectangle parentBounds = dialog.getOwner().getBounds();
  dialog.setLocation(parentBounds.x + (parentBounds.width - bounds.width) / 2,
      parentBounds.y + (parentBounds.height - bounds.height) / 2);
  dialog.setVisible(true);
}
origin: org.zaproxy/zap

private void centreOnOwner() {
  Dimension frameSize = this.getSize();
  Rectangle mainrect = getOwner().getBounds();
  int x = mainrect.x + (mainrect.width - frameSize.width) / 2;
  int y = mainrect.y + (mainrect.height - frameSize.height) / 2;
  this.setLocation(x, y);
}
origin: eu.mihosoft.vrl/vrl

/**
 * Centers a frame on parent frame.
 *
 * @param parent parent frame
 * @param frame the frame to center
 */
public static void centerOnWindow(Window parent, Window frame) {
  Rectangle screenBounds = parent.getBounds();
  int x = screenBounds.x
      + screenBounds.width / 2 - frame.getWidth() / 2;
  int y = screenBounds.y
      + screenBounds.height / 2 - frame.getHeight() / 2;
  frame.setLocation(x, y);
}
origin: bcdev/beam

  @Override
  public void actionPerformed(ActionEvent e) {
    LayerSourceAssistantPane pane = new LayerSourceAssistantPane(SwingUtilities.getWindowAncestor(control),
                                   "Add Layer",
                                   getAppContext());
    LayerSourceDescriptor[] layerSourceDescriptors = BeamUiActivator.getInstance().getLayerSources();
    pane.show(new SelectLayerSourceAssistantPage(layerSourceDescriptors), screenBounds);
    screenBounds = pane.getWindow().getBounds();
  }
}
origin: net.anwiba.commons/anwiba-commons-swing-core

public static void center(final Window window) {
 if (window == null) {
  return;
 }
 final Window owner = window.getOwner();
 if (owner == null || owner.getBounds().equals(new Rectangle(0, 0, 0, 0))) {
  centerToScreen(window);
  return;
 }
 final int x = owner.getX() + owner.getWidth() / 2 - window.getWidth() / 2;
 final int y = owner.getY() + owner.getHeight() / 2 - window.getHeight() / 2;
 window.setLocation(x < 0 ? 0 : x, y < 0 ? 0 : y);
}
java.awtWindowgetBounds

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
  • removeWindowListener
    Removes the specified window listener so that it no longer receives window events from this window.
  • getGraphicsConfiguration
    This method returns the GraphicsConfiguration used by this Window.
  • removeWindowListener,
  • getGraphicsConfiguration,
  • 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
  • Best IntelliJ 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