* Stop the applet. Kill any sorting algorithm that
* is still sorting.
*/
@Override
publicsynchronizedvoidstop(){
if(algorithm!=null){
if(algorithm!=null){
try{
algorithm.stop();
}catch(IllegalThreadStateExceptione){
...
...
@@ -279,35 +280,42 @@ public class SortItem
}
}
@Override
publicvoidmouseClicked(MouseEvente){
showStatus(getParameter("alg"));
}
@Override
publicvoidmousePressed(MouseEvente){
}
/**
* The user clicked in the applet. Start the clock!
*/
@Override
publicvoidmouseReleased(MouseEvente){
startSort();
e.consume();
}
@Override
publicvoidmouseEntered(MouseEvente){
}
@Override
publicvoidmouseExited(MouseEvente){
}
@Override
publicStringgetAppletInfo(){
return"Title: SortDemo \nAuthor: James Gosling 1.17f, 10 Apr 1995 \nA simple applet class to demonstrate a sort algorithm. \nYou can specify a sorting algorithm using the 'alg' attribute. \nWhen you click on the applet, a thread is forked which animates \nthe sorting algorithm.";
}
@Override
publicString[][]getParameterInfo(){
String[][]info={
{"alg","string","The name of the algorithm to run. You can choose from the provided algorithms or suppply your own, as long as the classes are runnable as threads and their names end in 'Algorithm.' BubbleSort is the default. Example: Use 'QSort' to run the QSortAlgorithm class."}
{"alg","string",
"The name of the algorithm to run. You can choose from the provided algorithms or suppply your own, as long as the classes are runnable as threads and their names end in 'Algorithm.' BubbleSort is the default. Example: Use 'QSort' to run the QSortAlgorithm class."}