I want to have my windows and dialogs open in the same size and location as their last usage. I am saving and restoring the size and location, but I'm not sure where best to restore them.
If I call setSize and setLocation inside the constructor, I get an "Overridable method call in constructor" warning. I understand why that is bad, so I want to make the call elsewhere. I've tried various window events such as windowOpened, componentShown, windowStateChanged, but they all have the effect of the window being brought up in the corner of the screen and then jumping to the desired location.
The best option I've come across is to make the class final. Then I can safely put the setSize and setLocation in the constructor. That feels like a cop out. The only other thing I've thought of is to put the burden on the caller, so instead of the usual:
new myDialog().setVisible (true);
make it
var dlg = new MyDialog ();
dlg.setSize (...);
dlg.setLocation (...);
dlg.setVisible (true);
But that's really putting the burden in the wrong place.
Is there an event that I'm missing that is invoked before the window is initially painted?