• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Centering dialogs in a multi-monitor environment?

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently, all of our dialogs seem to center themselves in the primary display. This is bad because the button that triggers the dialog may be 4 monitors away. I'm trying to get the dialog box to center on the screen where the action occured.

My current solution involves passing a Point object that represents the location of the action into the method that eventually shows the dialog. From this Point, I'm trying get the object (GraphicsConfiguration?) that represents the screen that contains this Point. My current code looks something like this:



As you can see, it's pretty much a mess. It works in some cases, but is unpredictable in others. If the main window is resized so that it takes up less than 1 screen, then everything seems OK. If I drag this window between monitors and try to show the dialog, it seems to center correctly on the proper display. There is a problem when the window is stretched to take up more than one screen, however. The dialog does not always appear on the correct display.

I can't possibly be the only person having this problem, but any information on how to properly support multi-monitor environments is pretty hard to come by. Is my understanding of the GraphicsConfiguration object correct? Does it represent the current display? Any one have any ideas? Thanks!
 
You showed up just in time for the waffles! And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic