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 44import java .util .*;
55
66public class Sorting extends Main {
7- // the main drawings
87 SortingAlgorithm sortAlgo = new SortingAlgorithm ();
98
10- // Values
11- ArrayList <Integer > list =new ArrayList <Integer >();//Creating arraylist
12-
139 // Panels
1410 JPanel pPanel1 , pPanel2 ;
1511
@@ -80,12 +76,14 @@ else if (e.getSource() == jbtMerge)
8076 System .out .println ("jbtMerge button clicked" );
8177 else if (e .getSource () == jbtBubble )
8278 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+ }
8582 else if (e .getSource () == jbtSelection )
8683 System .out .println ("jbtSelection button clicked" );
87- else if (e .getSource () == jbtStart )
84+ else if (e .getSource () == jbtStart ) {
8885 System .out .println ("jbtStart button clicked" );
86+ }
8987
9088 // setVisible(false); // will close the previous window
9189 }
Original file line number Diff line number Diff line change 55import java .awt .geom .Rectangle2D ;
66import java .util .Random ;
77
8- import javax .swing .JFrame ;
98import javax .swing .JPanel ;
10- import javax .swing .SwingUtilities ;
119import javax .swing .SwingWorker ;
1210
1311public class SortingAlgorithm extends JPanel {
@@ -22,6 +20,11 @@ public class SortingAlgorithm extends JPanel {
2220 setBackground (Color .BLACK );
2321 setPreferredSize (new Dimension (WIDTH , HEIGHT ));
2422 initBarHeight (); // initialize the height of each bar
23+ //initSorter();
24+ initShuffler ();
25+ }
26+
27+ public void startSorting () {
2528 initSorter ();
2629 initShuffler ();
2730 }
@@ -108,5 +111,4 @@ public void swap(int indexA, int indexB) {
108111 bar_height [indexA ] = bar_height [indexB ];
109112 bar_height [indexB ] = temp ;
110113 }
111-
112114}
You can’t perform that action at this time.
0 commit comments