Swing GUI With Progress Bar Threaded Joins
Hi all
i am new to java and this forum hope i have this posted in correct place...
i have a GUI when a button is pushed it will zoom off with a progress bar, that all works fine, the problem is when i put more tasks to do in the same action it will stop the progress bar from showing when i use .join???
when i use the join it waits for the thread to complete then start next thread which i do want but when run the progress bar remains @0 untill that thread completes then starts the second without showing or updateing the progress bar 1...
any help will be great.. thanks
FINE=
Code:
Button 1 Actionlistner=
demuxThread startDemuxThread = new demuxThread();
startDemuxThread.start();
NOT WORKING=
Code:
demuxThread startDemuxThread = new demuxThread();
startDemuxThread.start();
try {
startDemuxThread.join();
} catch (InterruptedException ex) {
Logger.getLogger(EncodingForm.class.getName()).log(Level.SEVERE, null, ex);
}
demuxThread2 startDemuxThread2 = new demuxThread2();
startDemuxThread2.start();
Thread Class =
Code:
class demuxThread extends Thread {
public demuxThread() {
}
public void run() {
while(true) {
Progress frame = new Progress();
frame.pack();
frame.setSize(190, 60);
frame.setVisible(true);
try
{
Runtime r = Runtime.getRuntime();
String cmd[] = { "ping" , "www.google.com" };
Process p = r.exec(cmd );
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String lineRead =null;
StringBuffer foo = new StringBuffer("");
outputArea.setText("initializing...");
demuxProgressBar.setIndeterminate(true);
while( (lineRead = reader.readLine() ) != null)
{
lineRead = lineRead.trim();
if(lineRead.contains("--")){}
else {
foo.append(lineRead).append("\n");
}
outputArea.setText(foo.toString());
System.out.println(lineRead);
demuxProgressBar.setIndeterminate(true);
}
}
catch(Exception e)
{
e.printStackTrace();
}
demuxProgressBar.setIndeterminate(false);
demuxProgressBar.setValue(100);
demuxLabel.setForeground(Color.green);
frame.setVisible(false);
return;
}
}
}