I want to have warning showConfirmDialog window in front of the application even if GUI moves to different position, it works fine if I don't move the application and press 'Close ALT+X' button, but if I move the application to second screen the warning showConfirmDialog window stays at the old position, how to move the warning window along with GUI, please give me directions, thanks.
Close ALT+X button
//close window button
JButton btnCloseWindow = new JButton("Close ALT+X");
btnCloseWindow.setMnemonic('x');
btnCloseWindow.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame frame = new JFrame();
int result = JOptionPane.showConfirmDialog(frame, "Are you sure you want to close the application?", "Please Confirm",JOptionPane.YES_NO_OPTION);
//find the position of GUI and set the value
//dialog.setLocation(10, 20);
if (result == JOptionPane.YES_OPTION)
System.exit(0);
}
});
SO far I tried to set position centre of the location of GUI to showConfirmDialog, but didn't work.