|
From: Ype K. <yk...@xs...> - 2001-10-16 17:53:11
|
>[Ype Kingma]
>>
>> I have run into the problem that when using swing it is necessary
>> to call java.lang.System.exit() to exit the process running the
>> jython interpreter.
>
>That's always true but from my point of view it's a sensible
>behaviour wrt to the thread based vs. loop based model
>used by Java GUIs. (I know it can be annoying if one uses
>only some input dialogs for instance )
>But it's inherited from pure Java GUI code, try:
>
>import javax.swing.*;
>
>public class JB {
>
> public static void main(String[] args) {
> JFrame f = new JFrame();
> f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
> JButton b = new JButton("Ok");
> f.getContentPane().add(b);
> f.pack();
> f.show();
>
> }
>
>}
>
>or
>
>import javax.swing.*;
>
>public class JOP {
>
> public static void main(String[] args) {
> int result = JOptionPane.showConfirmDialog(null,
> "Will an answer leave the app?", "?",
> JOptionPane.YES_NO_OPTION);
> }
>
>}
>
>Otherwise one would have to put some unnatural wait
>or loop in the main thread.
Which is what I have to do before calling System.exit().
Waiting for all (non deamon) java threads to die is a possibility,
but it does not feel correct to wait for non jython
threads (eg. the swing thread) in a jython implementation.
The current tactic of doing nothing leaves all the freedom
ever needed.
Regards,
Ype
|