Java JFrame setDialogLocation(JFrame frame, JFrame parentFrame)

Here you can find the source of setDialogLocation(JFrame frame, JFrame parentFrame)

Description

Sets the dialogLocation attribute of the TapUtils class

License

Open Source License

Parameter

Parameter Description
frame The new dialogLocation value
parentFrame The new dialogLocation value

Declaration

public static void setDialogLocation(JFrame frame, JFrame parentFrame) 

Method Source Code


//package com.java2s;
/*//from w ww  .  ja va  2 s. c om
 *  Copyright (C) 2003 by Francois Guillet
 *  This program is free software; you can redistribute it and/or modify it under the
 *  terms of the GNU General Public License as published by the Free Software
 *  Foundation; either version 2 of the License, or (at your option) any later version.
 *  This program 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 General Public License for more details.
 */

import java.awt.*;

import javax.swing.*;

public class Main {
    /**
     *  Sets the dialogLocation attribute of the TapUtils class
     *
     *@param  frame        The new dialogLocation value
     *@param  parentFrame  The new dialogLocation value
     */
    public static void setDialogLocation(JFrame frame, JFrame parentFrame) {
        Point location = new Point();
        location.x = parentFrame.getLocation().x + parentFrame.getWidth() / 2 - frame.getWidth() / 2;
        location.y = parentFrame.getLocation().y + parentFrame.getHeight() / 2 - frame.getHeight() / 2;
        if (location.x < 0)
            location.x = 0;
        if (location.y < 0)
            location.y = 0;
        frame.setLocation(location);
    }
}

Related

  1. run(JFrame frame, int width, int height)
  2. saveFrame(Class pClass, JFrame pFrame, String pFrameId)
  3. saveMainWindowLocation(JFrame jfrm, String strPropertiesFilePath, String strPropertiesFileName)
  4. setBlockAllUserInput(final JFrame frame, final boolean yesNo)
  5. setCursorFree(JFrame frame)
  6. setDirty(JFrame frame, boolean isDirty)
  7. setEscapeAction(JFrame frame, Action action)
  8. setEscapeClosable(JFrame frame)
  9. setESCCloseable(final JFrame aFrame)