Here you can find the source of dialogYesNo(JFrame frame, String title, String message, Object[] options)
public static int dialogYesNo(JFrame frame, String title, String message, Object[] options)
//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; } }