| 1 |
import java.awt.event.ActionEvent; |
|---|
| 2 |
import java.awt.event.ActionListener; |
|---|
| 3 |
import java.util.ArrayList; |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
public abstract class ThreadedActionListener extends Thread implements ActionListener, Cloneable { |
|---|
| 15 |
ThreadedActionListener thread = null; |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
public void actionPerformed(ActionEvent arg0) { |
|---|
| 20 |
try { |
|---|
| 21 |
|
|---|
| 22 |
if ((thread != null && !thread.isAlive()) || thread == null) { |
|---|
| 23 |
|
|---|
| 24 |
thread = (ThreadedActionListener)this.clone(); |
|---|
| 25 |
thread.start(); |
|---|
| 26 |
} |
|---|
| 27 |
} |
|---|
| 28 |
catch (Exception e) { |
|---|
| 29 |
System.out.println("Exception thrown while cloning. This shouldn't happen"); |
|---|
| 30 |
} |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
public abstract void run(); |
|---|
| 37 |
|
|---|
| 38 |
} |
|---|