Here you can find the source of setDialogLocation(JFrame frame, JFrame parentFrame)
Parameter | Description |
---|---|
frame | The new dialogLocation value |
parentFrame | The new dialogLocation value |
public static void setDialogLocation(JFrame frame, JFrame parentFrame)
//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); } }