Java JFrame Size locateWindow(JFrame parent, Dimension mySize, Dimension offset, JDialog me)

Here you can find the source of locateWindow(JFrame parent, Dimension mySize, Dimension offset, JDialog me)

Description

A helper to position a dialog

License

Open Source License

Declaration


public static void locateWindow(JFrame parent, Dimension mySize, Dimension offset, JDialog me) 

Method Source Code

//package com.java2s;
/*//from w w w  .  j a v  a  2 s.c o  m
**    Copyright (C) 2003-2012 Institute for Systems Biology 
**                            Seattle, Washington, USA. 
**
**    This library is free software; you can redistribute it and/or
**    modify it under the terms of the GNU Lesser General Public
**    License as published by the Free Software Foundation; either
**    version 2.1 of the License, or (at your option) any later version.
**
**    This library is distributed in the hope that it will be useful,
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
**    Lesser General Public License for more details.
**
**    You should have received a copy of the GNU Lesser General Public
**    License along with this library; if not, write to the Free Software
**    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

import java.awt.Dimension;

import java.awt.Point;

import java.awt.Toolkit;

import javax.swing.JFrame;

import javax.swing.JDialog;

public class Main {
    /***************************************************************************
    **
    ** A helper to position a dialog
    */

    public static void locateWindow(JFrame parent, Dimension mySize, Dimension offset, JDialog me) {
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension parSize = parent.getSize();
        Point p = parent.getLocation();
        int rightX = p.x + parSize.width;
        if (rightX > screen.width) {
            rightX = screen.width;
        }
        int topY = p.y;
        Point myUL = new Point(rightX - mySize.width - offset.width, topY + offset.height);
        me.setLocation(myUL);
        return;
    }
}

Related

  1. getFramesCurrentScreenSize(JFrame currentFrame)
  2. getFrameSize(Component c)
  3. getFrameSize(Component c)
  4. getFrameSize(Component c)
  5. isNormalSizeMode(JFrame window)
  6. lockInMinSize(final JFrame frame)
  7. positionFrame(final JFrame frame, final Dimension viewSize, final int addX, final int addY)
  8. resizeApp(JFrame app)
  9. restrictWindowMinimumSize(final JInternalFrame frame, final Dimension minSize)