X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FJvOptionPane.java;h=99ab26f7cd419decd6c3c519e23e57f95c227356;hb=b81011230fbb6ed9286b4d1a7136a4535978e3db;hp=020890b392b35aa3271c64d007cf35ba78c0f8a5;hpb=847c502d6186eb62a30f37f608852e77c67c217f;p=jalview.git diff --git a/src/jalview/gui/JvOptionPane.java b/src/jalview/gui/JvOptionPane.java index 020890b..99ab26f 100644 --- a/src/jalview/gui/JvOptionPane.java +++ b/src/jalview/gui/JvOptionPane.java @@ -60,6 +60,7 @@ import javax.swing.event.InternalFrameListener; import jalview.bin.Console; import jalview.util.ChannelProperties; +import jalview.util.MessageManager; import jalview.util.Platform; import jalview.util.dialogrunner.DialogRunnerI; @@ -1553,11 +1554,24 @@ public class JvOptionPane extends JOptionPane } public static JvOptionPane frameDialog(String message, String title, - int messageType, String[] buttonsText, String defaultButton, + int messageType, String[] buttonsTextS, String defaultButtonS, Callable[] 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++) { @@ -1581,15 +1595,24 @@ public class JvOptionPane extends JOptionPane { dialogType = JOptionPane.YES_NO_CANCEL_OPTION; } - jvop.setResponseHandler(JOptionPane.YES_OPTION, handlers[0]); + Callable nullCallable = () -> { + return null; + }; + jvop.setResponseHandler(JOptionPane.YES_OPTION, + (handlers != null && handlers.length > 0) ? handlers[0] + : nullCallable); if (dialogType == JOptionPane.YES_NO_OPTION || dialogType == JOptionPane.YES_NO_CANCEL_OPTION) { - jvop.setResponseHandler(JOptionPane.NO_OPTION, handlers[1]); + jvop.setResponseHandler(JOptionPane.NO_OPTION, + (handlers != null && handlers.length > 1) ? handlers[1] + : nullCallable); } if (dialogType == JOptionPane.YES_NO_CANCEL_OPTION) { - jvop.setResponseHandler(JOptionPane.CANCEL_OPTION, handlers[2]); + jvop.setResponseHandler(JOptionPane.CANCEL_OPTION, + (handlers != null && handlers.length > 2) ? handlers[2] + : nullCallable); } final int dt = dialogType;