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 zeigeAlleTasks;
private JTextArea AllTasksArea;
private JButton clear;
public GUI_UserInterface() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
@ -57,6 +58,10 @@ public class GUI_UserInterface extends JFrame {
zeigeAlleTasks.setBounds(193, 506, 159, 29);
panel.add(zeigeAlleTasks);
clear = new JButton("Clear TextArea");
clear.setBounds(384, 506, 159, 29);
panel.add(clear);
setLocationRelativeTo(null);
this.setVisible(true);
}
@ -76,6 +81,14 @@ public class GUI_UserInterface extends JFrame {
public void setAllTasksArea(JTextArea 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.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.table.DefaultTableModel;
import TodoListApp.Domain.*;
@ -97,6 +96,7 @@ public class GUI_addTask extends JFrame {
submitTask = new JButton("Submit");
submitTask.setBounds(24, 323, 123, 23);
panel.add(submitTask);
setLocationRelativeTo(null);
}
public void zeigeFensterAddTask() {

View File

@ -8,14 +8,15 @@ public class Userverwalter {
private ProgrammSystem system;
private GUI_UserInterface user;
private GUI_addTask taskHinziFuegenFenster;
private int index = 0;
public Userverwalter() {
this.system = new ProgrammSystem();
this.user = new GUI_UserInterface();
this.taskHinziFuegenFenster = new GUI_addTask();
this.system = new ProgrammSystem();
this.user = new GUI_UserInterface();
this.taskHinziFuegenFenster = new GUI_addTask();
// Buttons User:
user.getAddTask().addActionListener(e -> {
// Buttons User:
user.getAddTask().addActionListener(e -> {
try {
zeigeFenster();
} catch (FalscheEinagebException e1) {
@ -24,7 +25,7 @@ public class Userverwalter {
}
});
taskHinziFuegenFenster.getSubmitTask().addActionListener(e -> {
taskHinziFuegenFenster.getSubmitTask().addActionListener(e -> {
try {
addTask();
} catch (FalscheEinagebException e1) {
@ -33,14 +34,14 @@ public class Userverwalter {
}
});
user.getZeigeAlleTasks().addActionListener(e -> showAllTasks());
user.getZeigeAlleTasks().addActionListener(e -> showAllTasks());
user.getClear().addActionListener(e -> clearTextArea());
}
public void zeigeFenster() throws FalscheEinagebException {
taskHinziFuegenFenster.zeigeFensterAddTask();
}
public void addTask() throws FalscheEinagebException {
@ -63,9 +64,23 @@ public class Userverwalter {
}
public void showAllTasks() {
for (String s : system.showAllTasks()) {
user.getAllTasksArea().append(s);
user.getAllTasksArea().append("\n");
if (system.showAllTasks().size() == 0)
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");
}
}
}
public void clearTextArea() {
user.getAllTasksArea().setText("");
index = 0;
}
}