Repainting a JPanel in a loop with a delay
问题 I'm trying to create a program which will visualize different sorting algorithms by drawing a set of bars representing an array along for each time the sort loops. However, when I set the array from within the sorter class which in turn repaints the panel, it seems that it only calls paintComponent() for the first and last iteration, not showing the steps in between. Here is the sort code which calls the setNumberArray() method: public void bubbleSort() { int[] x = getNumberArray(); boolean