tasks Zeigen

master
3009594 2024-10-11 00:51:42 +02:00
parent 3826d33c6b
commit 509f9372dd
3 changed files with 52 additions and 24 deletions

View File

@ -13,6 +13,7 @@ public class GUI_UserInterface extends JFrame {
private JButton addTask; private JButton addTask;
private JButton zeigeAlleTasks; private JButton zeigeAlleTasks;
private JTextArea AllTasksArea; private JTextArea AllTasksArea;
private JButton clear;
public GUI_UserInterface() { public GUI_UserInterface() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE ); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
@ -57,6 +58,10 @@ public class GUI_UserInterface extends JFrame {
zeigeAlleTasks.setBounds(193, 506, 159, 29); zeigeAlleTasks.setBounds(193, 506, 159, 29);
panel.add(zeigeAlleTasks); panel.add(zeigeAlleTasks);
clear = new JButton("Clear TextArea");
clear.setBounds(384, 506, 159, 29);
panel.add(clear);
setLocationRelativeTo(null);
this.setVisible(true); this.setVisible(true);
} }
@ -76,6 +81,14 @@ public class GUI_UserInterface extends JFrame {
public void setAllTasksArea(JTextArea allTasksArea) { public void setAllTasksArea(JTextArea allTasksArea) {
AllTasksArea = allTasksArea; AllTasksArea = allTasksArea;
} }
public void showInfo(String message) {
JOptionPane.showMessageDialog(null, message, "Studen angemeldet", JOptionPane.INFORMATION_MESSAGE);
}
public JButton getClear() {
return clear;
}
} }

View File

@ -5,7 +5,6 @@ import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder; import javax.swing.border.LineBorder;
import javax.swing.table.DefaultTableModel;
import TodoListApp.Domain.*; import TodoListApp.Domain.*;
@ -97,6 +96,7 @@ public class GUI_addTask extends JFrame {
submitTask = new JButton("Submit"); submitTask = new JButton("Submit");
submitTask.setBounds(24, 323, 123, 23); submitTask.setBounds(24, 323, 123, 23);
panel.add(submitTask); panel.add(submitTask);
setLocationRelativeTo(null);
} }
public void zeigeFensterAddTask() { public void zeigeFensterAddTask() {

View File

@ -8,6 +8,7 @@ public class Userverwalter {
private ProgrammSystem system; private ProgrammSystem system;
private GUI_UserInterface user; private GUI_UserInterface user;
private GUI_addTask taskHinziFuegenFenster; private GUI_addTask taskHinziFuegenFenster;
private int index = 0;
public Userverwalter() { public Userverwalter() {
this.system = new ProgrammSystem(); this.system = new ProgrammSystem();
@ -34,13 +35,13 @@ public class Userverwalter {
}); });
user.getZeigeAlleTasks().addActionListener(e -> showAllTasks()); user.getZeigeAlleTasks().addActionListener(e -> showAllTasks());
user.getClear().addActionListener(e -> clearTextArea());
} }
public void zeigeFenster() throws FalscheEinagebException { public void zeigeFenster() throws FalscheEinagebException {
taskHinziFuegenFenster.zeigeFensterAddTask(); taskHinziFuegenFenster.zeigeFensterAddTask();
} }
public void addTask() throws FalscheEinagebException { public void addTask() throws FalscheEinagebException {
@ -63,9 +64,23 @@ public class Userverwalter {
} }
public void showAllTasks() { public void showAllTasks() {
for (String s : system.showAllTasks()) { if (system.showAllTasks().size() == 0)
user.getAllTasksArea().append(s); user.showInfo("Momentan befinden sich keine Taks");
else if (index >= system.showAllTasks().size())
user.showInfo("Es gibt keine Tasks mehr!");
else {
while (index < system.showAllTasks().size()) {
user.getAllTasksArea().append(system.showAllTasks().get(index++));
user.getAllTasksArea().append("\n"); user.getAllTasksArea().append("\n");
} }
} }
}
public void clearTextArea() {
user.getAllTasksArea().setText("");
index = 0;
}
} }