1515import sortvisualiser .MainApp ;
1616import sortvisualiser .algorithms .*;
1717
18-
1918public final class MainMenuScreen extends Screen {
19+ <<<<<<< HEAD
2020 private static final Color BACKGROUND_COLOUR = Color .BLUE ; //defining color of background
2121 private final ArrayList <AlgorithmCheckBox > checkBoxes ;
2222
2323 public MainMenuScreen (MainApp app ) {
2424 super (app );
2525 checkBoxes = new ArrayList <>(); //array that contains the checkboxes
2626 setUpGUI ();
27+ =======
28+ private static final Color BACKGROUND_COLOUR = Color .BLUE ; // sets the background color
29+ private final ArrayList <AlgorithmCheckBox > checkBoxes ; // creates an arraylist for the checkboxes in the GUI screen
30+
31+ public MainMenuScreen (MainApp app ) {
32+ super (app );
33+ checkBoxes = new ArrayList <>(); // we initialised the checkbox arraylist
34+ setUpGUI (); //called the setUpGUI method defined below
35+ >>>>>>> 6 a5781b83e4af42e6dddad64f872c76d885b4356
2736 }
2837
29- private void addCheckBox (ISortAlgorithm algorithm , JPanel panel ) {
38+ private void addCheckBox (ISortAlgorithm algorithm , JPanel panel ) { //add the checkboxes for sorting algos in the mainMenuScreen of GUI window
3039 JRadioButton box = new JRadioButton ("" , true );
3140 box .setAlignmentX (Component .LEFT_ALIGNMENT );
3241 box .setBackground (BACKGROUND_COLOUR );
@@ -35,19 +44,26 @@ private void addCheckBox(ISortAlgorithm algorithm, JPanel panel) {
3544 panel .add (box );
3645 }
3746
38- private void initContainer (JPanel p ) {
47+ private void initContainer (JPanel p ) { //Container class init() method
3948 p .setLayout (new BoxLayout (p , BoxLayout .PAGE_AXIS ));
4049 p .setBackground (BACKGROUND_COLOUR );
4150 }
4251
52+ <<<<<<< HEAD
4353 public void setUpGUI () {
4454 JPanel sortAlgorithmContainer = new JPanel ();
4555 JPanel optionsContainer = new JPanel ();
56+ =======
57+ public void setUpGUI () { // method created to setup the GUI window, i.e setting background and alignment
58+ JPanel sortAlgorithmContainer = new JPanel (); // object for sorting array window
59+ JPanel optionsContainer = new JPanel (); // object for main menu class i.e, with the radio buttons for sort algos
60+ >>>>>>> 6 a5781b83e4af42e6dddad64f872c76d885b4356
4661 JPanel outerContainer = new JPanel ();
4762 initContainer (this );
4863 initContainer (optionsContainer );
4964 initContainer (sortAlgorithmContainer );
5065
66+ <<<<<<< HEAD
5167 outerContainer .setBackground (BACKGROUND_COLOUR );
5268 outerContainer .setLayout (new BoxLayout (outerContainer , BoxLayout .LINE_AXIS ));
5369
@@ -60,6 +76,10 @@ public void setUpGUI() {
6076 } catch (IOException e ) {
6177 System .out .println ("Unable to load logo" );
6278 }
79+ =======
80+ outerContainer .setBackground (BACKGROUND_COLOUR ); // set the background color
81+ outerContainer .setLayout (new BoxLayout (outerContainer , BoxLayout .LINE_AXIS )); // set the layout
82+ >>>>>>> 6 a5781b83e4af42e6dddad64f872c76d885b4356
6383
6484 sortAlgorithmContainer .setAlignmentX (Component .LEFT_ALIGNMENT );//Examples of components are the buttons, checkboxes, and scrollbars of a typical graphical user interface
6585 addCheckBox (new BubbleSort (), sortAlgorithmContainer );
@@ -69,7 +89,12 @@ public void setUpGUI() {
6989 addCheckBox (new InsertionSort (), sortAlgorithmContainer );
7090 addCheckBox (new RadixSort (), sortAlgorithmContainer );
7191
92+ <<<<<<< HEAD
7293 JButton startButton = new JButton ("Start" ); //button text
94+ =======
95+
96+ JButton startButton = new JButton ("Start" ); // start button for mainmenu in GUI
97+ >>>>>>> 6 a5781b83e4af42e6dddad64f872c76d885b4356
7398 startButton .addActionListener ((ActionEvent e ) -> {
7499 ArrayList <ISortAlgorithm > algorithms = new ArrayList <>();
75100 for (AlgorithmCheckBox cb : checkBoxes ) {
@@ -97,7 +122,7 @@ public void setUpGUI() {
97122 }
98123
99124 @ Override
100- public void onOpen () {
125+ public void onOpen () { // unchecks all the radiobutton
101126 checkBoxes .forEach ((box ) -> {
102127 box .unselect ();
103128
@@ -129,4 +154,4 @@ public ISortAlgorithm getAlgorithm() {
129154 }
130155 }
131156
132- }
157+ }
0 commit comments