I'm new to
Java and also new to Swing but if this post should be in the Swing forum, please let me know.
My program has a class called Gui which extends JFrame. Gui has a panel at the bottom called statusBar which has a label on it called status. Gui has a public method defined as:
I use this for the obvious reason: showing the current status at various points during the program according to user interaction.
There is also a menu and when the user selects one of the menu items a method is called which runs an external command using the following code inside a try-catch:
where cmd is the command to run in
String format. The ellipsis (...) represents some stream-handling code designed to redirect the output of the command into a file. The exitVal isn't used.
Now, the problem is that when the user selects this menu item the very first thing I do before calling the external command is to show what's happening on the status line with:
where gui is the only instance of Gui in the program. And what's happening is that the text isn't being shown until after the external command has finished.
I don't know if it makes a difference but at the moment, the code for gui is running on the main
thread as this is mostly
test code.
How can I get the text on the status label to show while the external command is running?