0

I have added frame.setLocationRelativeTo(null);, but it still opens to the left of the screen when the application is ran.

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Login frame = new Login();
                frame.pack();
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
  • Something is going on inside your `Login` class - consider providing a runnable example which demonstrates your issue - Also, any answer that suggests `Toolkit#getScreenSize` as mechanism for resolving the issue is wrong and should be ignored (and deleted) – MadProgrammer Nov 21 '17 at 00:32
  • I have no errors inside my Login class, how would I demonstrate my issue? just through screen shots? – Paolok59717 Nov 21 '17 at 00:37
  • 3
    [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) - You might not have any "errors", but you are doing something wrong which can't be diagnosed without the addition of the `Login` source - my "guess" is, you're creating two windows – MadProgrammer Nov 21 '17 at 00:39

0 Answers0