private void setCenteredInParent(final JFrame parent) {
		final Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
		final int screenWidth = d.getSize().width, screenHeight = d.getSize().height, parentWidth = parent
				.getSize().width, parentHeight = parent.getSize().height, w = this.getSize().width, h = this
				.getSize().height;
		final Point p = parent.getLocation(), setp = parent.getLocation();
		if (p.x < 0)
			setp.x = (parentWidth + p.x - w) / 2;
		else if (p.x + parentWidth > screenWidth)
			setp.x = p.x + (screenWidth - p.x - w) / 2;
		else
			setp.x = p.x + (parentWidth - w) / 2;
		if (p.y < 0)
			setp.y = (parentHeight + p.y - h) / 2;
		else if (p.y + parentHeight > screenHeight)
			setp.y = p.y + (screenHeight - p.y - h) / 2;
		else
			setp.y = p.y + (parentHeight - h) / 2;
		if (setp.x < 0)
			setp.x = 0;
		else if (setp.x + w > screenWidth)
			setp.x = screenWidth - w;
		if (setp.y < 0)
			setp.y = 0;
		else if (p.y + h > screenHeight)
			setp.y = screenHeight - h;
		setLocation(setp);
	}