OOP-Projects-Java

Log | Files | Refs | README

commit 04bc5d6ca64fa1bbb37162e302d1305c53b08bcd
parent b93877098725d3b978219796086f28c95a00810c
Author: William Lindholm <william_lindholm@outlook.com>
Date:   Mon, 13 Feb 2023 13:46:08 +0100

Created separate method for updating task count

Diffstat:
MOOP2023_a22willi_a21liltr_assignment2/src/assignment2/TaskHandler.java | 18+++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/OOP2023_a22willi_a21liltr_assignment2/src/assignment2/TaskHandler.java b/OOP2023_a22willi_a21liltr_assignment2/src/assignment2/TaskHandler.java @@ -29,7 +29,7 @@ public class TaskHandler implements TaskListener { completedTaskCount = 0; taskProgress = new JLabel(); taskProgress.setHorizontalAlignment(JLabel.CENTER); - taskProgress.setText(completedTaskCount + " out of " + taskList.getComponentCount() + " tasks completed."); + updateTaskProgress(); } public JScrollPane GetScrollPane() { @@ -85,7 +85,7 @@ public class TaskHandler implements TaskListener { public void taskCompleted(Task t) { // TODO Auto-generated method stub completedTaskCount++; - taskProgress.setText(completedTaskCount + " out of " + taskList.getComponentCount() + " tasks completed."); + updateTaskProgress(); //update the frame to show currently visible tasks. SwingUtilities.updateComponentTreeUI(taskList); @@ -95,7 +95,7 @@ public class TaskHandler implements TaskListener { public void taskUncompleted(Task t) { // TODO Auto-generated method stub completedTaskCount--; - taskProgress.setText(completedTaskCount + " out of " + taskList.getComponentCount() + " tasks completed."); + updateTaskProgress(); //update the frame to show currently visible tasks. SwingUtilities.updateComponentTreeUI(taskList); @@ -107,7 +107,7 @@ public class TaskHandler implements TaskListener { t.setTaskListener(this); taskList.add(t.getGuiComponent()); - taskProgress.setText(completedTaskCount + " out of " + taskList.getComponentCount() + " tasks completed."); + updateTaskProgress(); //update the frame to show currently visible tasks. SwingUtilities.updateComponentTreeUI(taskList); @@ -121,10 +121,18 @@ public class TaskHandler implements TaskListener { completedTaskCount--; } - taskProgress.setText(completedTaskCount + " out of " + taskList.getComponentCount() + " tasks completed."); + updateTaskProgress(); //update the frame to show currently visible tasks. SwingUtilities.updateComponentTreeUI(taskList); } + + /* + * Updates the task progress to show the current amount + * of tasks. + */ + private void updateTaskProgress() { + taskProgress.setText(completedTaskCount + " out of " + taskList.getComponentCount() + " tasks completed."); + } }