+
+ // run through buttons for initialValue first so can set a final
+ // timeoutThreadF
+ Thread timeoutThread = null;
+ for (int i = 0; i < options.length; i++)
+ {
+ Object o = options[i];
+ JButton jb = buttons[i];
+ if (o.equals(initialValue))
+ {
+ initialValueButton = jb;
+ if (timeout > 0 && initialValueButton != null
+ && initialValueButton instanceof JButton)
+ {
+ Runnable timeoutClose = () -> {
+ try
+ {
+ Thread.sleep(timeout);
+ } catch (InterruptedException e)
+ {
+ Console.debug(
+ "Dialog timeout interrupted. Probably a button pressed.");
+ }
+ jb.doClick();
+ };
+ timeoutThread = new Thread(timeoutClose);
+ }
+ }
+ }
+ final Thread timeoutThreadF = timeoutThread;
+ timeoutThreadF.start();
+