Inserir valor no Quicksort

Creio que quase todo mundo já viu este código.

[code]import java.util.Arrays;
import java.util.Random;

public class QuickSort<? super E>> {
public static final Random RND = new Random();

private void swap(E[] array, int i, int j) {
    E tmp = array[i];
    array[i] = array[j];
    array[j] = tmp;
}

private int partition(E[] array, int begin, int end) {
    int index = begin + RND.nextInt(end - begin + 1);
    E pivot = array[index];
    swap(array, index, end);
    for (int i = index = begin; i < end; ++i) {
        if (array[i].compareTo(pivot) <= 0) {
            swap(array, index++, i);
        }
    }
    swap(array, index, end);
    return (index);
}

private void qsort(E[] array, int begin, int end) {
    if (end > begin) {
        int index = partition(array, begin, end);
        qsort(array, begin, index - 1);
        qsort(array, index + 1, end);
    }
}

public void sort(E[] array) {
    qsort(array, 0, array.length - 1);
}

// Exemplo de uso
public static void main(String[] args) {

    // Ordenando Inteiros
    Integer[] l1 = { 5, 1024, 1, 88, 0, 1024 };
    System.out.println("l1  start:" + Arrays.toString(l1));
    QuickSort<Integer> qs = new QuickSort<Integer>();
    qs.sort(l1);
    System.out.println("l1 sorted:" + Arrays.toString(l1));

    // Ordenando Strings
    String[] l2 = { "gamma", "beta", "alpha", "zoolander" };
    System.out.println("l2  start:" + Arrays.toString(l2));
    QuickSort<String> qs2 = new QuickSort<String>();
    qs2.sort(l2);
    System.out.println("l2 sorted:" + Arrays.toString(l2));
}

}
[/code]

Neste exemplo acima os valores são passados automaticamente, com este código.

Integer[] l1 = { 5, 1024, 1, 88, 0, 1024 };

Agora vem a pergunta:
Como faço para que eu insira em um jtextfield o valor e seja armazenado em vez de ser passado automaticamente.

Obrigado.

Bem digamos que a sua tela, que conterá o JTextField, tenha o campo onde será inserido o número, tenha também dois botões um para confirmar o número que será inserido e outro para fazer a ordenação dos valores. Você poderia usar um ArrayList para armazenar os valores enquanto o usuário estiver adicionando-os, e depois que o usuário clicar em no botão que ordena, você tem duas opções, a 1° é passa todos os valores que estão contidos no ArrayList para um vetor comum, ou fazer a ordenação pelo próprio ArrayList. Como o seu código está fazendo a ordenação utilizando um vetor comum, passe os valores do ArrayList para o vetor.

ex: De como capturar o número na inserção

public void InsertActionPerformed(java.awt.event.ActionEvent evt) {
          array.add(Integer.parseInt(textField.getText()));
}

Cara, este QuickSort que acredito que vc pegou do Wikipedia está muito complicado…
Se quiser tem este aqui que só usa arrays:

[code]public class QuickSort {

public static void main(String args[]) {
    int a[] = {2, 5, 3, 0, 1, 4};

    quicksort(a, 0, a.length - 1);

    for (int i = 0; i < a.length; i++) {
        System.out.print(a[i] + " ");
    }
    System.out.println();
}

public static void swap(int a[], int x, int y) {
    int temp = a[x];
    a[x] = a[y];
    a[y] = temp;
}

public static int partition(int a[], int f, int l) {
    int pivo = a[f];
    while (f < l) {

        while (a[f] < pivo) {
            f++;
        }
        while (a[l] > pivo) {
            l--;
        }
        swap(a, f, l);
    }
    return f;
}

public static void quicksort(int a[], int f, int l) {
    if (f >= l) {
        return;
    }
    int pivotIndex = partition(a, f, l);
    quicksort(a, f, pivotIndex);
    quicksort(a, pivotIndex + 1, l);
}

}[/code]

Fonte: http://gauss.ececs.uc.edu/Courses/C321/html/quicksort.java.html

Por que será que dá erro nesta linha do código?

 quicksort(a, 0, a.length - 1);