0

I'm developing an Eclipse Plug-in. There is one JFrame popup which user can choose settings.

My problem is to show this window in the center of Eclipse, as Eclipse does when you want to quit, it says "Confirm Exit", in the center of the screen.

Please note that user may use multiple monitors. setLocationRelativeTo(null) doesn't work for this.

I've found one solution for multiple monitors How do I center a JDialog on screen?, Jean's answer. However it's quite long and I thought Eclipse PDE should have a component that I can use setLocationRelativeTo.

Thanks!

Community
  • 1
  • 1
Halil Kaskavalci
  • 1,920
  • 19
  • 29
  • It should have worked. If you post code, you might get answer soon. – nebula Dec 09 '11 at 15:57
  • I never seen better answer as by @Andrew Thompson, http://stackoverflow.com/questions/7143287/how-to-best-position-swing-guis/7143398#7143398 – mKorbel Dec 09 '11 at 16:03
  • mKorbel, I tried setLocationByPlatform(true), for multiple monitors it always show the window in first monitor and it doesn't remember the last position of it. – Halil Kaskavalci Dec 09 '11 at 16:15
  • aneal, what should have worked? I didn't try Jean's answer since it's long. I was looking if there is a content in Eclipse IDE that I can set this window relative to it. I don't want to create a whole class just for window positioning. – Halil Kaskavalci Dec 09 '11 at 16:16
  • I don't understand your complaint that it "doesn't remember the last position of it." Either it always centers the dialog against the workspace, or it doesn't - presumably persisting the location between invocations would violate this...? – Edward Thomson Dec 09 '11 at 17:49
  • Edward, If I set setLocationByPlaform(true) OS handles window positioning and it always creates the window in Monitor 1, somewhere close to left corner. Imagine Eclipse is in Monitor 2, and each time even though user drags the window, it will appear on Monitor 1, left corner. It is annoying. That's why that option doesn't work for me. – Halil Kaskavalci Dec 09 '11 at 17:58

0 Answers0