Can someone show simple Java Swing code/web resource that will position the popup dialog center-aligned on top of an existing JFrame window when the JFrame’s button clicked?
Can someone show simple Java Swing code/web resource that will position the popup dialog
Share
Oh..it’s pretty simple:
Say you have a JFrame that contains a JDialog, and you want the JDialog (when opened) to be right on top of JFrame.
So in JDialog constructor, you should have something like:
In other words, pass JFrame pointer to your dialog, and call setLocationRelativeTo(…); method.