private static boolean interactiveMode = true;
+ public static final Callable<Void> NULLCALLABLE = () -> {
+ return null;
+ };
+
private Component parentComponent;
private ExecutorService executor = Executors.newCachedThreadPool();
}
}
- public void showInternalDialog(JPanel mainPanel, String title,
+ public void showInternalDialog(Object mainPanel, String title,
int yesNoCancelOption, int questionMessage, Icon icon,
Object[] options, String initresponse)
{
this.setMessage(mainPanel);
ourOptions = Arrays.asList(options);
- int response;
if (parentComponent != this
&& !(parentComponent == null && Desktop.instance == null))
{
public JvOptionPane setResponseHandler(Object response,
Callable<Void> action)
{
+ if (action == null)
+ {
+ action = NULLCALLABLE;
+ }
callbacks.put(response, action);
return this;
}
public ExecutorService getExecutor()
{
if (executor == null)
- executor = Executors.newSingleThreadExecutor();
+ executor = Executors.newCachedThreadPool();
return executor;
}
}
}
- public static JvOptionPane frameDialog(String message, String title,
+ public static JvOptionPane frameDialog(Object message, String title,
int messageType, String[] buttonsTextS, String defaultButtonS,
- Callable<Void>[] handlers, boolean modal)
+ List<Callable<Void>> handlers, boolean modal)
{
JFrame parent = new JFrame();
JvOptionPane jvop = JvOptionPane.newOptionDialog();
{
dialogType = JOptionPane.YES_NO_CANCEL_OPTION;
}
- Callable<Void> nullCallable = () -> {
- return null;
- };
jvop.setResponseHandler(JOptionPane.YES_OPTION,
- (handlers != null && handlers.length > 0) ? handlers[0]
- : nullCallable);
+ (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.length > 1) ? handlers[1]
- : nullCallable);
+ (handlers != null && handlers.size() > 1) ? handlers.get(1)
+ : NULLCALLABLE);
}
if (dialogType == JOptionPane.YES_NO_CANCEL_OPTION)
{
jvop.setResponseHandler(JOptionPane.CANCEL_OPTION,
- (handlers != null && handlers.length > 2) ? handlers[2]
- : nullCallable);
+ (handlers != null && handlers.size() > 2) ? handlers.get(2)
+ : NULLCALLABLE);
}
final int dt = dialogType;