+
+ public static JvOptionPane frameDialog(String message, String title,
+ int messageType, String[] buttonsText, String defaultButton,
+ Callable<Void>[] handlers, boolean modal)
+ {
+ JFrame parent = new JFrame();
+ JvOptionPane jvop = JvOptionPane.newOptionDialog();
+ JButton[] buttons = new JButton[buttonsText.length];
+ for (int i = 0; i < buttonsText.length; i++)
+ {
+ buttons[i] = new JButton();
+ buttons[i].setText(buttonsText[i]);
+ Console.debug("DISABLING BUTTON " + buttons[i].getText());
+ buttons[i].setEnabled(false);
+ buttons[i].setVisible(false);
+ }
+
+ int dialogType = -1;
+ if (buttonsText.length == 1)
+ {
+ dialogType = JOptionPane.OK_OPTION;
+ }
+ else if (buttonsText.length == 2)
+ {
+ dialogType = JOptionPane.YES_NO_OPTION;
+ }
+ else
+ {
+ dialogType = JOptionPane.YES_NO_CANCEL_OPTION;
+ }
+ jvop.setResponseHandler(JOptionPane.YES_OPTION, handlers[0]);
+ if (dialogType == JOptionPane.YES_NO_OPTION
+ || dialogType == JOptionPane.YES_NO_CANCEL_OPTION)
+ {
+ jvop.setResponseHandler(JOptionPane.NO_OPTION, handlers[1]);
+ }
+ if (dialogType == JOptionPane.YES_NO_CANCEL_OPTION)
+ {
+ jvop.setResponseHandler(JOptionPane.CANCEL_OPTION, handlers[2]);
+ }
+
+ final int dt = dialogType;
+ jvop.getExecutor().execute(() -> {
+ jvop.showDialog(message, title, dt, messageType, null, buttonsText,
+ defaultButton, modal, buttons);
+ });
+
+ return jvop;
+ }