import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class SortAnw extends JFrame implements Runnable
{
    Thread uhr;
    Liste zahlen;
    
    public SortAnw()
    {
        zahlen = new Liste();
        zahlen.erzeugen();
        
        setSize(500,500);
        setTitle("Sortieren-Anwendung");
        setResizable(false);
        setVisible(true);
        run();
    }

    public void start()
    {
        if (uhr == null)
        {
            uhr = new Thread(this);
            uhr.start();
        }
    }

    public void run() 
    {
        for (int i=0; i<100; i++)
        {
            zahlen.insertionsortNextStep(i);
            repaint();
            try { Thread.sleep(200); }
            catch (InterruptedException e) { }
        }
    }     
    
    public void paint(Graphics g)
    {
        zahlen.paint(g);
    }

    public static void main(String[] args) 
    {
        new SortAnw();
    }
}