public void QUICKSORT(int[] A, int p, int r) {
if(p < r)
{
q=PARTITION(A,p,r);
labelPartitionPoint.setText("Partition point = "+q);
Thread.sleep(3000);
QUICKSORT(A,p,q-1);
QUICKSORT(A,q+1,r);
}
}
最佳答案
如果您在外部线程中执行此操作,则必须使用 Swing 实用程序 invokeLater(或 invokeAndWait)安排 EDT 内 Swing 组件状态的更新。
public void QUICKSORT(int[] A, int p, int r) {
if(p < r)
{
q=PARTITION(A,p,r);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
lblPartitionPoint.setText("Partition point = "+q);
}
});
Thread.sleep(3000);
QUICKSORT(A,p,q-1);
QUICKSORT(A,q+1,r);
}
}
关于java - 在排序运行时将值设置为一个 jLabel 和 textBoxes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18737896/