Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- public class GUI {
- public static void main(String[] args) {
- JFrame frame = new JFrame("Option Dialog Example");
- int result = JOptionPane.showConfirmDialog(frame, "Do you want to save the changes?");
- System.out.println(result);
- if (result == JOptionPane.YES_OPTION) {
- System.out.println("User clicked 'Yes'");
- } else if (result == JOptionPane.NO_OPTION) {
- System.out.println("User clicked 'No'");
- } else {
- System.out.println("User clicked 'Cancel'");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement