Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Centre window on leftmost screen with multiple monitors

 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cheers Nate, very helpful
 
So I left, I came home, and I ate some pie. And then I read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!