Dimension screen = win.getToolkit().getScreenSize(); x = (screen.width - width) / 2; y = (screen.height - height) / 2;
Component parent = win.getParent(); if(parent == null) { Dimension screen = win.getToolkit().getScreenSize(); x = (screen.width - width) / 2; y = (screen.height - height) / 2; } else { Rectangle bounds = parent.getBounds(); x = bounds.x + (bounds.width - width) / 2; y = bounds.y + (bounds.height - height) / 2; }
	public static void loadGeometry(Window win, String name)	{		int x, y, width, height;		try		{			width = Integer.parseInt(jEdit.getProperty(name + ".width"));			height = Integer.parseInt(jEdit.getProperty(name + ".height"));		}		catch(NumberFormatException nf)		{			Dimension size = win.getSize();			width = size.width;			height = size.height;		}		try		{			x = Integer.parseInt(jEdit.getProperty(name + ".x"));			y = Integer.parseInt(jEdit.getProperty(name + ".y"));		}		catch(NumberFormatException nf)		{			Dimension screen = win.getToolkit().getScreenSize();			x = (screen.width - width) / 2;			y = (screen.height - height) / 2;		}		win.setLocation(x,y);		win.setSize(width,height);		// workaround for broken Linux JDK		if(System.getProperty("os.name").indexOf("Linux") != -1)			win.addWindowListener(new LinuxWorkaround(win,x,y,width,height));	}