commit fb77b4756e28dc232c8ed9a4e6b920e82ceda861
parent f9c5c72f1f9f5aad5c7eca831456211b04d92a20
Author: William Lindholm <william_lindholm@outlook.com>
Date: Wed, 15 Feb 2023 17:19:24 +0100
Fixed Color changing functionality
Diffstat:
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/OOP2023_a22willi_a21liltr_assignment2/src/assignment2/GUI.java b/OOP2023_a22willi_a21liltr_assignment2/src/assignment2/GUI.java
@@ -43,8 +43,8 @@ public class GUI implements ActionListener {
frame.add(menu, BorderLayout.NORTH);
taskHandler = new TaskHandler();
- frame.add(taskHandler.GetScrollPane());
- frame.add(taskHandler.GetTaskProgress(), BorderLayout.SOUTH);
+ frame.add(taskHandler.getScrollPane());
+ frame.add(taskHandler.getTaskProgress(), BorderLayout.SOUTH);
frame.setVisible(true);
}
@@ -63,7 +63,7 @@ public class GUI implements ActionListener {
/*
- * Used to create generic dialogueboxes
+ * Used to create generic dialogue boxes
*
* @param String[] options List of options available to the user.
* @param String label Title shown to user during selection process.
@@ -80,18 +80,18 @@ public class GUI implements ActionListener {
/*
- * Handles actions performed by the user eg buttonclicks.
+ * Handles actions performed by the user e.g. button clicks.
*
- * @param ActionEvent e tracks all occuring events.
+ * @param ActionEvent e tracks all occurring events.
*/
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(buttons.get("sort"))) {
- //Open dialoguebox where user can choose sorting algorithm
+ //Open dialogue box where user can choose sorting algorithm
String[] sortingOptions = {"Alphabetical", "Type", "Completed"};
String selectedOption = SelectionBox("Choose Sorting type", sortingOptions);
- taskHandler.Sort(selectedOption);
+ taskHandler.sort(selectedOption);
}
else {
Task t;
@@ -102,7 +102,9 @@ public class GUI implements ActionListener {
t = new StudyTask();
}
else {
- t = new WorkTask();
+ String[] colors = {"BLACK", "RED", "GREEN", "BLUE"};
+ String selectedColor = SelectionBox("Choose color", colors);
+ t = new WorkTask(selectedColor);
}
taskHandler.taskCreated(t);
}
diff --git a/OOP2023_a22willi_a21liltr_assignment2/src/assignment2/TaskHandler.java b/OOP2023_a22willi_a21liltr_assignment2/src/assignment2/TaskHandler.java
@@ -33,15 +33,15 @@ public class TaskHandler implements TaskListener {
updateTaskProgress();
}
- public JScrollPane GetScrollPane() {
+ public JScrollPane getScrollPane() {
return scrollPane;
}
- public JLabel GetTaskProgress() {
+ public JLabel getTaskProgress() {
return taskProgress;
}
- public void Sort(String sortingOption) {
+ public void sort(String sortingOption) {
List<Task> sortedList = new ArrayList<Task>();
for (int i = 0; i < taskList.getComponentCount(); i++) {
sortedList.add((Task)taskList.getComponent(i));