void NewJDialogcallone(JFrame frame)
{
location = frame.getLocationOnScreen();
int x = location.x;
int y = location.y;
dialog.setLocation(x, y);
dialog.setLocationRelativeTo(frame);
dialog.setVisible(true);
dialog.setAlwaysOnTop(true);
dialog.addComponentListener(this);
}
public void componentMoved(ComponentEvent e,?????)
{
JOptionPane.showConfirmDialog (null,
"This is the \"Ok/Cancel\"message dialog box.",
"",
JOptionPane.OK_CANCEL_OPTION);
}
I want to use the frame object so that the dialog box moves relative to the parent frame a.k.a. I move the parent frame and the dialog box moves with it.I want to call dialog.setLocationRelativeTo(//parent frame object//)
, which is possible only if I have the parent frame object.
If there is any way to get this window behaviour, please help me.