Java JFrame dialogYesNo(JFrame frame, String title, String message, Object[] options)

Here you can find the source of dialogYesNo(JFrame frame, String title, String message, Object[] options)

Description

dialog Yes No

License

Open Source License

Declaration

public static int dialogYesNo(JFrame frame, String title, String message, Object[] options) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class Main {
    public static int dialogYesNo(JFrame frame, String title, String message, Object[] options) {
        JOptionPane pane = new JOptionPane(message);
        pane.setOptions(options);/*from  w w  w .  j  av a2s  .c o m*/
        JDialog dialog = pane.createDialog(frame, title);
        dialog.setVisible(true);
        Object obj = pane.getValue();
        for (int i = 0; i < options.length; i++) {
            if (options[i].equals(obj)) {
                return i;
            }
        }
        return -1;
    }
}

Related

  1. createConfirmOnExitAdapter(final JFrame frame, final String title, final String message)
  2. createDialogForPanel(JFrame parent, JPanel panel)
  3. createPackedJFrame( java.awt.Component content, String title, int closeOperation)
  4. decorateFrame(JFrame frame, JMenuBar menuBar)
  5. deleteFile(String filepath, JFrame parent)
  6. dispAlert(JFrame pFrame, String pTask, String pMessaggio)
  7. dispErrore(JFrame frame, String task, String mess)
  8. display(JFrame parent, JInternalFrame dialog)
  9. displayConfirmationMessage(JFrame parent, String message, String title)