@@ -63,6 +63,8 @@ public AsyncDialog() {
6363 private ActionListener actionListener ;
6464 private Object choice ;
6565 private Object [] options ;
66+ private Object value ;
67+ private boolean wantsInput ;
6668
6769 // These options can be supplemented as desired.
6870
@@ -81,13 +83,15 @@ public static String showInputDialog(Component frame, String msg) {
8183
8284 public void showInputDialog (Component frame , Object message , ActionListener a ) {
8385 setListener (a );
86+ wantsInput = true ;
8487 process (JOptionPane .showInputDialog (frame , message ));
8588 unsetListener ();
8689 }
8790
8891 public void showInputDialog (Component frame , Object message , String title , int messageType , Icon icon ,
8992 Object [] selectionValues , Object initialSelectionValue , ActionListener a ) {
9093 setListener (a );
94+ wantsInput = true ;
9195 process (JOptionPane .showInputDialog (frame , message , title , messageType , icon , selectionValues ,
9296 initialSelectionValue ));
9397 unsetListener ();
@@ -214,21 +218,21 @@ private void unsetListener() {
214218 */
215219 @ Override
216220 public void propertyChange (PropertyChangeEvent evt ) {
217- Object val = evt .getNewValue ();
221+ value = evt .getNewValue ();
218222 switch (evt .getPropertyName ()) {
219223 case "inputValue" :
220- process (val );
224+ process (value );
221225 break ;
222226 case "value" :
223- if (val != null && options == null && !(val instanceof Integer )) {
224- process (getOptionIndex (((JOptionPane ) evt .getSource ()).getOptions (), val ));
227+ if (value != null && options == null && !(value instanceof Integer )) {
228+ process (getOptionIndex (((JOptionPane ) evt .getSource ()).getOptions (), value ));
225229 return ;
226230 }
227231 if (options != null ) {
228- int i = getOptionIndex (options , val );
229- val = Integer .valueOf (i >= 0 ? i : JOptionPane .CLOSED_OPTION );
232+ int i = getOptionIndex (options , value );
233+ value = Integer .valueOf (i >= 0 ? i : JOptionPane .CLOSED_OPTION );
230234 }
231- process (val );
235+ process (value );
232236 break ;
233237 }
234238 }
@@ -242,6 +246,13 @@ private int getOptionIndex(Object[] options, Object val) {
242246 return -1 ;
243247 }
244248
249+ public Object getValue () {
250+ if (wantsInput || options == null )
251+ return value ;
252+ int val = ((Integer ) value ).intValue ();
253+ return (val < 0 ? null : options [val ]);
254+ }
255+
245256 private boolean processed ;
246257
247258 /**
0 commit comments