Advertisement
RupeshAcharya60

Option Dialogs

Mar 25th, 2023
621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | Source Code | 0 0
  1. import javax.swing.*;
  2.  
  3. public class GUI {
  4.     public static void main(String[] args) {
  5.         JFrame frame = new JFrame("Option Dialog Example");
  6.  
  7.         int result = JOptionPane.showConfirmDialog(frame, "Do you want to save the changes?");
  8.         System.out.println(result);
  9.         if (result == JOptionPane.YES_OPTION) {
  10.  
  11.             System.out.println("User clicked 'Yes'");
  12.         } else if (result == JOptionPane.NO_OPTION) {
  13.             System.out.println("User clicked 'No'");
  14.         } else {
  15.             System.out.println("User clicked 'Cancel'");
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement