Here is the simple code that has two JoptionPane
.
currently, it has no buttons, but I want to attach button to the second JOptionPane
for Yes or NO event.
Moreover, when the two JOptionPanes
are closed, the Frame
does not close.Is there a way to force close Frame
when JoptionPanes
are closed.
here is my current code
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class TestJoption {
public static void main(String[] args){
JFrame frame = new JFrame("Game");
JOptionPane.showMessageDialog(frame, "You Won!", "Winner", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(frame, "yes No", "play again", JOptionPane.INFORMATION_MESSAGE);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}