git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-629 null check and neatening code
[jalview.git]
/
src
/
jalview
/
gui
/
JvOptionPane.java
diff --git
a/src/jalview/gui/JvOptionPane.java
b/src/jalview/gui/JvOptionPane.java
index
0a7c49e
..
8edab03
100644
(file)
--- a/
src/jalview/gui/JvOptionPane.java
+++ b/
src/jalview/gui/JvOptionPane.java
@@
-859,8
+859,9
@@
public class JvOptionPane extends JOptionPane
break NOTNULL;
}
break NOTNULL;
}
- // run through buttons for initialValue first so can set a final
- // timeoutThreadF
+ // run through buttons for initialValue first so we can set (and start)
+ // a final timeoutThreadF to include (and interrupt) in the button
+ // actions
Thread timeoutThread = null;
for (int i = 0; i < options.length; i++)
{
Thread timeoutThread = null;
for (int i = 0; i < options.length; i++)
{
@@
-868,11
+869,10
@@
public class JvOptionPane extends JOptionPane
JButton jb = buttons[i];
if (o.equals(initialValue))
{
JButton jb = buttons[i];
if (o.equals(initialValue))
{
- initialValueButton = jb;
- if (timeout > 0 && initialValueButton != null
- && initialValueButton instanceof JButton)
+ if (timeout > 0 && jb != null && jb instanceof JButton)
{
{
- Runnable timeoutClose = () -> {
+ // after timeout ms click the default button
+ timeoutThread = new Thread(() -> {
try
{
Thread.sleep(timeout);
try
{
Thread.sleep(timeout);
@@
-882,13
+882,17
@@
public class JvOptionPane extends JOptionPane
"Dialog timeout interrupted. Probably a button pressed.");
}
jb.doClick();
"Dialog timeout interrupted. Probably a button pressed.");
}
jb.doClick();
- };
- timeoutThread = new Thread(timeoutClose);
+ });
}
}
+ initialValueButton = jb;
+ break;
}
}
final Thread timeoutThreadF = timeoutThread;
}
}
final Thread timeoutThreadF = timeoutThread;
- timeoutThreadF.start();
+ if (timeoutThreadF != null)
+ {
+ timeoutThreadF.start();
+ }
int[] buttonActions = { JOptionPane.YES_OPTION,
JOptionPane.NO_OPTION, JOptionPane.CANCEL_OPTION };
int[] buttonActions = { JOptionPane.YES_OPTION,
JOptionPane.NO_OPTION, JOptionPane.CANCEL_OPTION };