public void gotoPrevious(){  
        
        /*
         * Goes to the previous step of sort 1, by decrementing the indexes
         * Decrements index2, if index2 is -1 then it decrements index1, if index1 is -1
         * that means your at the first step and its sets both indexes to 0.
         */ 
        if(panelArea1index2>=0)
            --panelArea1index2;
        if(panelArea1index2==-1){
            --panelArea1index1;
            
            if(panelArea1index1==-1){
                panelArea1index1=panelArea1index2=0;
            }
            else  
                panelArea1index2=steps1[panelArea1index1].length-1;
        }
        
        //Paints the image found from the above indexes
        panelArea1.draw(panelArea1index1, panelArea1index2);
        txtBoxDialogPanel1(); 
      
        /*
         * Goes to the previous step of sort 2 if enabled, by decrementing the indexes
         * Decrements index2, if index2 is -1 then it decrements index1, if index1 is -1
         * that means your at the first step and its sets both indexes to 0.
         */ 
        if ( secondSortEnabled ){
            if(panelArea2index2>=0)
                --panelArea2index2;
            if(panelArea2index2==-1){
                --panelArea2index1;
            
                if(panelArea2index1==-1){
                    panelArea2index1=panelArea2index2=0;
                }
                else  
                    panelArea2index2=steps2[panelArea2index1].length-1;
            }
        //Paints second sort image if enabled
        panelArea2.draw(panelArea2index1, panelArea2index2);
        txtBoxDialogPanel2(); 
        }    
    }