Examples of JOptionPane?

   JOptionPane.showMessageDialog(frame, "File successfully imported!");

   JOptionPane.showMessageDialog(frame, "Deprecated version", "Warning", 
                                 JOptionPane.WARNING_MESSAGE);

   JOptionPane.showMessageDialog(frame, "Error importing file!", "Error", 
                                 JOptionPane.ERROR_MESSAGE);

   JOptionPane.showMessageDialog(frame, "File successfully imported!", "Message", 
                                 JOptionPane.PLAIN_MESSAGE);

   JOptionPane.showMessageDialog(frame, "File successfully imported?", "Question",
                                 JOptionPane.QUESTION_MESSAGE);

   ImageIcon icon = new ImageIcon("thumbsup.gif");
   JOptionPane.showMessageDialog(frame, "File successfully imported!", "Hey", 
                                 JOptionPane.INFORMATION_MESSAGE, icon);

   int status = JOptionPane.showOptionDialog(frame, "Are you sure you want to import this file?", 
                                             "Question", JOptionPane.YES_NO_CANCEL_OPTION, 
                                             JOptionPane.QUESTION_MESSAGE, null, null, null);
   System.out.println("Option " + status + " selected!");

   Object[] options = { "Ja", "Nee", "Annuleren", "Test" };
   status = JOptionPane.showOptionDialog(frame, "Ben je zeker dat je dit bestand wilt importeren?",
                                         "vraag", -1, JOptionPane.QUESTION_MESSAGE, null,
                                         options, options[2]);
   System.out.println("Option " + status + " selected!");

   options = new Object[] { "Yes, please", "No, thanks" };
   status = JOptionPane.showOptionDialog(frame, "Error importing, try again?", "Question",
                                         -1, JOptionPane.ERROR_MESSAGE, null,
                                         options, options[0]);
   System.out.println("Option " + status + " selected!");

   String value = JOptionPane.showInputDialog("Please enter your name"); 
   System.out.println("You entered: " + value);

   options = new Object[] { "male", "female" };
   value = (String) JOptionPane.showInputDialog(frame, "Select your sex", "Input", 
                                                JOptionPane.QUESTION_MESSAGE, icon, options, 
                                                options[1]); 
   System.out.println("You entered: " + value);

   JDesktopPane desktop = new JDesktopPane(); 
   frame.setContentPane(desktop);
   frame.setSize(new Dimension(400, 200));
   frame.setLocation(100, 100);
   frame.setVisible(true);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
   status = JOptionPane.showInternalOptionDialog(desktop, "Are you sure you want to import this file?", 
                                                 "Question", JOptionPane.YES_NO_CANCEL_OPTION, 
                                                 JOptionPane.QUESTION_MESSAGE, null, null, null);
   System.out.println("Option " + status + " selected!");

The complete working example: Main.java:

import javax.swing.*;
import java.awt.*;
 
public class Main
{
   public static void main(String []args) {
      JFrame frame = new JFrame();
 
      // #1 
      JOptionPane.showMessageDialog(frame, "File successfully imported!");
 
      // #2
      JOptionPane.showMessageDialog(frame, "Deprecated version", "Warning", 
                                    JOptionPane.WARNING_MESSAGE);
 
      // #3
      JOptionPane.showMessageDialog(frame, "Error importing file!", "Error", 
                                    JOptionPane.ERROR_MESSAGE);
      
      // #4
      JOptionPane.showMessageDialog(frame, "File successfully imported!", "Message", 
                                    JOptionPane.PLAIN_MESSAGE);
 
      // #5
      JOptionPane.showMessageDialog(frame, "File successfully imported?", "Question",
                                    JOptionPane.QUESTION_MESSAGE);
 
      // #6
      ImageIcon icon = new ImageIcon("thumbsup.gif");
      JOptionPane.showMessageDialog(frame, "File successfully imported!", "Hey", 
                                    JOptionPane.INFORMATION_MESSAGE, icon);
 
      // #7
      int status = JOptionPane.showOptionDialog(frame, "Are you sure you want to import this file?", 
                                                "Question", JOptionPane.YES_NO_CANCEL_OPTION, 
                                                JOptionPane.QUESTION_MESSAGE, null, null, null);
      System.out.println("Option " + status + " selected!");
 
      // #8
      Object[] options = { "Ja", "Nee", "Annuleren", "Test" };
      status = JOptionPane.showOptionDialog(frame, "Ben je zeker dat je dit bestand wilt importeren?",
                                            "vraag", -1, JOptionPane.QUESTION_MESSAGE, null,
                                            options, options[2]);
      System.out.println("Option " + status + " selected!");
 
      // #9
      options = new Object[] { "Yes, please", "No, thanks" };
      status = JOptionPane.showOptionDialog(frame, "Error importing, try again?", "Question",
                                            -1, JOptionPane.ERROR_MESSAGE, null,
                                            options, options[0]);
      System.out.println("Option " + status + " selected!");
 
      // #10
      String value = JOptionPane.showInputDialog("Please enter your name"); 
      System.out.println("You entered: " + value);
      
      // #11
      options = new Object[] { "male", "female" };
      value = (String) JOptionPane.showInputDialog(frame, "Select your sex", "Input", 
                                                   JOptionPane.QUESTION_MESSAGE, icon, options, 
                                                   options[1]); 
      System.out.println("You entered: " + value);
 
      // #12
      JDesktopPane desktop = new JDesktopPane(); 
      frame.setContentPane(desktop);
      frame.setSize(new Dimension(400, 200));
      frame.setLocation(100, 100);
      frame.setVisible(true);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
      status = JOptionPane.showInternalOptionDialog(desktop, "Are you sure you want to import this file?", 
                                                    "Question", JOptionPane.YES_NO_CANCEL_OPTION, 
                                                    JOptionPane.QUESTION_MESSAGE, null, null, null);
      System.out.println("Option " + status + " selected!");
 
      System.exit(1);
   }
}