I am busy creating an interface using Java/Swing and I want to make the interface generate in the center of the screen when it is run. I am not using Drag and Drop so I need to code this feature in. I found in other posts on here two ways this can be done:
One way was:
this.pack();
this.setLocationRelativeTo(null)
and the other was:
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize()
this.setLocation(dim.width/6-this.getSize().width/5, dim.height/6-this.getSize().height/5);
Both of these options work in a sense the frame no longer generates in the top left corner of the screen but now it is generated in the bottom right of my screen with most of the frame cut off. The second option's values were originally set to 2 but the values 5 and 6 were the closest I could get the frame to appear in the center but it was still quite a bit off.
Is there any way I can fix this? Could it be a resolution issue?