File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 4
4
import java .util .*;
5
5
6
6
public class Sorting extends Main {
7
- // the main drawings
8
7
SortingAlgorithm sortAlgo = new SortingAlgorithm ();
9
8
10
- // Values
11
- ArrayList <Integer > list =new ArrayList <Integer >();//Creating arraylist
12
-
13
9
// Panels
14
10
JPanel pPanel1 , pPanel2 ;
15
11
@@ -80,12 +76,14 @@ else if (e.getSource() == jbtMerge)
80
76
System .out .println ("jbtMerge button clicked" );
81
77
else if (e .getSource () == jbtBubble )
82
78
System .out .println ("jbtBubble button clicked" );
83
- else if (e .getSource () == jbtInsertion )
84
- new SortingAlgorithm (); // Sorting algotithm
79
+ else if (e .getSource () == jbtInsertion ) {
80
+ sortAlgo .startSorting (); // Sorting algotithm
81
+ }
85
82
else if (e .getSource () == jbtSelection )
86
83
System .out .println ("jbtSelection button clicked" );
87
- else if (e .getSource () == jbtStart )
84
+ else if (e .getSource () == jbtStart ) {
88
85
System .out .println ("jbtStart button clicked" );
86
+ }
89
87
90
88
// setVisible(false); // will close the previous window
91
89
}
Original file line number Diff line number Diff line change 5
5
import java .awt .geom .Rectangle2D ;
6
6
import java .util .Random ;
7
7
8
- import javax .swing .JFrame ;
9
8
import javax .swing .JPanel ;
10
- import javax .swing .SwingUtilities ;
11
9
import javax .swing .SwingWorker ;
12
10
13
11
public class SortingAlgorithm extends JPanel {
@@ -22,6 +20,11 @@ public class SortingAlgorithm extends JPanel {
22
20
setBackground (Color .BLACK );
23
21
setPreferredSize (new Dimension (WIDTH , HEIGHT ));
24
22
initBarHeight (); // initialize the height of each bar
23
+ //initSorter();
24
+ initShuffler ();
25
+ }
26
+
27
+ public void startSorting () {
25
28
initSorter ();
26
29
initShuffler ();
27
30
}
@@ -108,5 +111,4 @@ public void swap(int indexA, int indexB) {
108
111
bar_height [indexA ] = bar_height [indexB ];
109
112
bar_height [indexB ] = temp ;
110
113
}
111
-
112
114
}
You can’t perform that action at this time.
0 commit comments