>>> If you use JOptionPane.showInputDialog, it will pass back a string
>>> value.
[quoted text clipped - 32 lines]
>> }
>> }
I whipped up the code without thinking but ...
> First of all, you're accessing an instance field (globalString) from a
> static method (getString).
Yeap, should be static.
> But even if you fix that, I think when getString() is called, the JFrame
> will be made visible, and the method will immediately return, regardless of
> what the user does. Most of the time, it'll return so fast, the user won't
> have time to do anything ,and so the getString() method will always return
> the empty string.
Nope, it blocks the static method until setVisible(false); or the x is
pressed.
> You need to . stop processing until the user dismisses the JFrame, in
> which case it's probably a better idea to use a JDialog than a JFrame
> anyway.
Huh?
Re-read:
public class StringDialog extends JDialog {...}
Oliver Wong - 27 Oct 2006 15:01 GMT
> Huh?
>
> Re-read:
>
> public class StringDialog extends JDialog {...}
This is the part I misread. For some reason, I thought you were
extending JFrame.
- Oliver
Lionel - 01 Nov 2006 00:09 GMT
>> Huh?
>>
[quoted text clipped - 4 lines]
> This is the part I misread. For some reason, I thought you were
> extending JFrame.
Good thing I forgot to post my code then :). And of course, if I was
extending JFrame then you would have been spot on. The confusion
probably came about because I said that you design the JDialog
contentpane in a similar way to a JFrame contentpane.
Lionel.
[...]
I'll post a full code later if you don't understand. You might find it
useful. I certainly find it a nice way to make dialog's just the way you
want them.
Lionel.