
Signature
'cat' is not recognized as an internal or external command,
operable program or batch file.
> From what I've read, using threads in a GUI application is tricky, and
> I'm ignorant of threads, anyway. So, I'm asking for confirmation that
> my thought about the freeze is correct, and suggestions about what
> might be happening with the logging and how I can "spin off" the
> method processing safely.
If your application takes some considerable amount of time
to process something, the GUI will freeze until the processing is
finished.
You can start a thread from GUI application, but you won't be
able to wait for notification that the thread task is finished.
Simply because it will freeze the GUI again.
My advice is to run a thread from the GUI, pass it some reference
of your GUI classes and show a screen that asks user to wait a moment.
When the processing thread is finished it should move the GUI
to the next screen. That's why it needs a reference to some GUI classes.
As an illustration, I had a GUI application that does a lot of
processing. I start a thread and pass it a reference to the
CardLayout that contains different screen definitions of my
applications. hen the processing is finished, it uses a reference
to CardLayout instance to return to main menu.
DG
Michael Powe - 22 May 2006 10:26 GMT
>> From what I've read, using threads in a GUI application is tricky, and
>> I'm ignorant of threads, anyway. So, I'm asking for confirmation that
>> my thought about the freeze is correct, and suggestions about what
>> might be happening with the logging and how I can "spin off" the
>> method processing safely.
> My advice is to run a thread from the GUI, pass it some reference
> of your GUI classes and show a screen that asks user to wait a moment.
> When the processing thread is finished it should move the GUI
> to the next screen. That's why it needs a reference to some GUI classes.
> As an illustration, I had a GUI application that does a lot of
> processing. I start a thread and pass it a reference to the
> CardLayout that contains different screen definitions of my
> applications. hen the processing is finished, it uses a reference
> to CardLayout instance to return to main menu.
Thank you for this idea, I will look into it. I understand what you
mean and I had not thought of this approach.
Thanks.
mp
Dražen Gemić - 22 May 2006 13:37 GMT
> Thank you for this idea, I will look into it. I understand what you
> mean and I had not thought of this approach.
Neither had I, in the beginning :-)
DG
> I have a simple GUI that runs some methods from a class that formerly
> was part of a commandline application.
This is ugly. Retro-fitting an CLI application with a GUI is ugly,
because the CLI application typically has a completely different control
flow than what is needed for a GUI application.
Consider reworking at least the control flow from scratch.
> sometimes freezes the UI
See Q3.1 and Q3.2 of the comp.lang.java.gui FAQ.
> From what I've read, using threads in a GUI application is tricky,
It's not tricky. There are three simple things to take care of. See Q4.2
of the FAQ.
> I'm ignorant of threads,
Well, that might be your main problem then.
> how I can "spin off" the
> method processing safely.
Learn about threads, learn the GUI's threading rules, and execute things
in separate threads - if needed.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
Michael Powe - 22 May 2006 10:25 GMT
>> I have a simple GUI that runs some methods from a class that formerly
>> was part of a commandline application.
> This is ugly. Retro-fitting an CLI application with a GUI is ugly,
> because the CLI application typically has a completely different control
> flow than what is needed for a GUI application.
Well, in this case there isn't any "control flow," as I am simply
calling some static methods which turn on or off certain Windows
services. This class was originally embedded in another application
and these methods _were_ used as part of a process, there.
One of the problems faced in this situation is that there appears to be
no documentation whatever on moving from a commandline application to a
GUI or "event-driven" one. I have several tools that I've written that
I would like to "transition" but I've put off having to figure it out
from scratch.
>> sometimes freezes the UI
> See Q3.1 and Q3.2 of the comp.lang.java.gui FAQ.
Thanks, I will.
>> From what I've read, using threads in a GUI application is tricky,
> It's not tricky. There are three simple things to take care of. See Q4.2
> of the FAQ.
See page 275 of _Java Examples in a Nutshell, 3rd edition_. David
Flanagan doesn't agree with you.
Thanks for the references. I will follow up on them.
mp