wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Centre window on leftmost screen with multiple monitors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Centre window on leftmost screen with multiple monitors" Watch "Centre window on leftmost screen with multiple monitors" New topic
Author

Centre window on leftmost screen with multiple monitors

Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
Hi,
Our user have multiple screens and I wanted to centre a JFrame on the leftmost of these screens. Unfortunately the display drivers we are using appear to represent the screen size as one large screen. i.e it represents 3* 1024 * 768 screens as 1 * 3072 * 768 screen.
I have tried :

but this returns one.
Anyone have any idea how I can display a window centred on the leftmost screen in such circumstances. Note users can have 1-6 screens.
thanks,
D
[ October 15, 2003: Message edited by: Don Kiddick ]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

If you know that they're going to be running in 1024 x 768 resolution then it's a simple matter of using a formula like this -


If their resolution can be variable as well as the number of monitors, you are basically going to have to guess. But you can make an educated guess - If you get a height of 480, the width is probably 640. If you get a height of 600, the width is probably 800. If you get a height of 768 the width is probably 1024, etc. You could also try to validate your guess a bit more by dividing the total screen width by the guessed width using modulus (%) and checking to make sure the result is 0.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
cheers Nate, very helpful
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Centre window on leftmost screen with multiple monitors
 
Similar Threads
Different windows on Java Perspective
Flow Design concern
CardLayout
pop-up window issue
how do i get window reference without re-opening?