0

My Swing application requires me to display a calendar in a JDialog box. The challenge I'm facing here is that the position of the JDialog box is not the same across screens of different sizes or resolutions.

I tried using the d.setLocation(x, y) of JDialog for positioning. And I know can get monitor sizes this way. But it didn't help me to place the dialog box appear at a same place across different screens.

Please help me resolve this issue.

Community
  • 1
  • 1
Aryan Venkat
  • 679
  • 1
  • 10
  • 34
  • 3
    *"The challenge I'm facing here is that the position of the JDialog box is not the same across screens of different sizes or resolutions."* Why should it? Personally as a user I'd prefer to see the location of the dialog to be set [relative to the parent component](http://stackoverflow.com/a/10036092/418556). Either that or in the center of the screen (`setLocationRelativeTo(null);` after `pack()` has been called) for a splash screen. – Andrew Thompson May 28 '15 at 12:08
  • 1
    Where you want to place your dialog? – Sergiy Medvynskyy May 28 '15 at 12:08
  • @SergiyMedvynskyy I want to place the dialog on the top right corner of the window, so the user should be able to see other parts of the app even whene the dialog is open, and that should be displayed the same way in any screen so any part of the dialog box shouldn't go out of the view port. – Aryan Venkat May 29 '15 at 06:58
  • @AndrewThompson I tried the solution offered by the link, but that didn't help me out, as in some screen resolutions, the dialog box goes out of the view port, which is against my client's requirement. – Aryan Venkat May 29 '15 at 06:59
  • Are you saying that the **frames also** go 'out of the view port'? Or is the dialog not shown centered over the frame? – Andrew Thompson May 29 '15 at 07:25
  • @AndrewThompson Frames ain't going out of the view port but a certain portion of the JDialog box is. Like the user will not be able to see the close button of the JDialog unless he drags it. – Aryan Venkat May 29 '15 at 08:19

0 Answers0