Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make generic helper for action threads
- Loading branch information
1 parent
1950fc7
commit 029df4c
Showing
3 changed files
with
46 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
package snowblossom.iceleaf; | ||
|
||
import java.awt.event.ActionListener; | ||
import java.awt.event.ActionEvent; | ||
|
||
|
||
/** | ||
* Need an action listener to do a bunch of stuff, outside of the GUI thread | ||
* use this. Just extend and implement threadActionPerformed. | ||
*/ | ||
public abstract class ThreadActionListener implements ActionListener | ||
{ | ||
|
||
/** | ||
* This will be run in its own new thread on each action fired to this action listener | ||
*/ | ||
public abstract void threadActionPerformed(ActionEvent e); | ||
|
||
public void actionPerformed(ActionEvent e) | ||
{ | ||
new ActionRunnerThread(e).start(); | ||
} | ||
|
||
public class ActionRunnerThread extends Thread | ||
{ | ||
private ActionEvent e; | ||
public ActionRunnerThread(ActionEvent e) | ||
{ | ||
this.e = e; | ||
} | ||
|
||
public void run() | ||
{ | ||
threadActionPerformed(e); | ||
} | ||
|
||
} | ||
|
||
} | ||
|