Pressing Yes/No on embedded JOptionPane has no effect
问题 I'm trying to add an exit confirmation check to JFrame but I want the dialog to be undecorated. I've figured I need to use custom JDialog and custom JOptionPane. frame.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent windowEvent) { JDialog dialog = new JDialog(); dialog.setUndecorated(true); JOptionPane pane = new JOptionPane("Are you sure that you want to exit?", JOptionPane.QUESTION_MESSAGE,JOptionPane.YES_NO_OPTION);