Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling three different JFrame forms using threads.

Status
Not open for further replies.

steffunator

Programmer
Jun 6, 2010
1
0
0
CR
Hello, I have a simple program that I have to build using threads and Jframe forms. I wish the second part were different, but that's how it was assigned.

Anyway, the program consists of using three different threads to call their corresponding window. Then using join() to kill them. The program cannot be finished until all three windows are closed...

For some reason when I click to close on any of the frames, they will all close at the same time. Each of them has its own JFrame form, so I'm not sure why this happens.

This is my code:

public class NewMain
{

/**
* @param args the command line arguments
*/

public static void main(String[] args)
{

Reporte heredia = new Reporte();
Reporte1 alajuela = new Reporte1();
Reporte2 cartago = new Reporte2();

Thread alaj = new Thread(alajuela);
Thread here = new Thread(heredia);
Thread cart = new Thread(cartago);

alaj.start();
here.start();
cart.start();

if (alaj.isAlive() && here.isAlive() && cart.isAlive()) {
try {
alaj.join();
here.join();
cart.join();
System.out.println("End.");
} catch (InterruptedException excepcion) {
System.out.println("Error.");
}
}

}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top