Thread: [See Bugtracker] Setting Window Position
View Single Post
  #1  
Old 06.05.2011, 16:00
darekkay darekkay is offline
Junior Loader
 
Join Date: Nov 2010
Posts: 13
Default Setting Window Position

Hey,
there is a bug with setting the window position. Here an example (System - Windows 7):

1. Use two monitors (e.g. laptop + external monitor)
2. Move jDownloader to the second monitor's workspace.
3. Exit jDownloader
4. Plug out the second monitor
5. Start jDownloader again

=> what happens: the application tries to set the saved window location. Since there is only one monitor now, you can see the window going outside the current range while opening. There is no way (at least i found none) to move the window back except plugging in the second monitor again and moving the window back to the first workspace. That's pretty annoying and should not be a big problem to fix it.

Since i experienced exactly the same problem while programming my own application, here's a quick solution:

Code:
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

int cX = ... // your saved x value
int cY = ... // your saved y value

if (cX >= screenSize.width-5 || cY >= screenSize.height-5)
	setLocation(0,0);
else
	setLocation(cX,cY);
The "-5" are optional but a better solution imho, since the re should be at least a little area of the window the user actually sees.

I hope I could help and this little, but annoying, bug gets fixed!

Last edited by Jiaz; 06.05.2011 at 18:09.
Reply With Quote