Cancel = 0, Close = 1, Yes = 2 Swing Dialog - Java Swing

Java examples for Swing:JOptionPane

Description

Cancel = 0, Close = 1, Yes = 2 Swing Dialog

Demo Code


//package com.java2s;
import java.awt.Frame;

import javax.swing.JOptionPane;

public class Main {
    /**//from   w w  w.j  av  a  2s .co  m
     * Cancel = 0, Close = 1, Yes = 2
     * @param question
     * @param frame
     * @return
     */
    public static int areYouSurePopup(String question, Frame frame) {
        Object[] options = { "Cancel", "Close", "Yes" };
        return JOptionPane.showOptionDialog(frame, question, "Warning",
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.WARNING_MESSAGE, null, options, options[0]);
    }
}

Related Tutorials