import javax.swing.*;

public class DialogDemo {

    private static void createAndShowGUI() {
        final JFrame frame = new JFrame("Dialog Demo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        

        JButton button = new JButton("Show Dialog");
        button.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    JOptionPane.showMessageDialog(frame,
                                                  "This is the message.",
                                                  "This is the title",
                                                  JOptionPane.INFORMATION_MESSAGE);
                }
            });

        
        frame.getContentPane().add(button);
        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
                }
            });
    }
}