+
+ public static JvOptionPane frameDialog(Object message, String title,
+ int messageType, String[] buttonsTextS, String defaultButtonS,
+ List<Runnable> handlers, boolean modal)
+ {
+ JFrame parent = new JFrame();
+ JvOptionPane jvop = JvOptionPane.newOptionDialog();
+ final String[] buttonsText;
+ final String defaultButton;
+ if (buttonsTextS == null)
+ {
+ String ok = MessageManager.getString("action.ok");
+ buttonsText = new String[] { ok };
+ defaultButton = ok;
+ }
+ else
+ {
+ buttonsText = buttonsTextS;
+ defaultButton = defaultButtonS;
+ }
+ 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 != null && handlers.size() > 0) ? handlers.get(0)
+ : NULLCALLABLE);
+ if (dialogType == JOptionPane.YES_NO_OPTION
+ || dialogType == JOptionPane.YES_NO_CANCEL_OPTION)
+ {
+ jvop.setResponseHandler(JOptionPane.NO_OPTION,
+ (handlers != null && handlers.size() > 1) ? handlers.get(1)
+ : NULLCALLABLE);
+ }
+ if (dialogType == JOptionPane.YES_NO_CANCEL_OPTION)
+ {
+ jvop.setResponseHandler(JOptionPane.CANCEL_OPTION,
+ (handlers != null && handlers.size() > 2) ? handlers.get(2)
+ : NULLCALLABLE);
+ }
+
+ final int dt = dialogType;
+ new Thread(() -> {
+ jvop.showDialog(message, title, dt, messageType, null, buttonsText,
+ defaultButton, modal, buttons);
+ }).start();
+
+ return jvop;
+ }
+
+ private static void setMenusEnabled(JMenuBar menubar, boolean b)
+ {
+ for (int i = 0; i < menubar.getMenuCount(); i++)
+ {
+ JMenu menu = menubar.getMenu(i);
+ menu.setEnabled(b);
+ }
+ }
+