From ee99d4ec886eb8cd07afcd95544c1d3887b25bf7 Mon Sep 17 00:00:00 2001 From: Marc Dimmerling Date: Fri, 9 Feb 2024 19:54:27 +0100 Subject: [PATCH 1/9] refactoring: SaveNoteKommi --- src/main/java/Notizbuch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Notizbuch.java b/src/main/java/Notizbuch.java index 7371aae..23247c2 100644 --- a/src/main/java/Notizbuch.java +++ b/src/main/java/Notizbuch.java @@ -42,7 +42,7 @@ public class Notizbuch extends JFrame implements ActionListener { } } - + // Methode zum Speichern von Notizen public void saveNote() { try (PrintWriter writer = new PrintWriter(new FileWriter("notizen.txt"))) { writer.print(getTextArea().getText()); From 07c6a6ae756291ef453b1d16958193a985150747 Mon Sep 17 00:00:00 2001 From: Marc Dimmerling Date: Fri, 9 Feb 2024 19:55:18 +0100 Subject: [PATCH 2/9] refactoring: LoadNoteKommi --- src/main/java/Notizbuch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Notizbuch.java b/src/main/java/Notizbuch.java index 23247c2..3dfeb42 100644 --- a/src/main/java/Notizbuch.java +++ b/src/main/java/Notizbuch.java @@ -51,7 +51,7 @@ public class Notizbuch extends JFrame implements ActionListener { JOptionPane.showMessageDialog(this, "Fehler beim Speichern der Notiz: " + e.getMessage()); } } - + // Methode zum Laden von Notizen public void loadNote() { try (BufferedReader reader = new BufferedReader(new FileReader("notizen.txt"))) { StringBuilder noteText = new StringBuilder(); From 9e0e3c6e97a5cb9573477b67a489ead095e4cb25 Mon Sep 17 00:00:00 2001 From: Marc Dimmerling Date: Fri, 9 Feb 2024 19:56:05 +0100 Subject: [PATCH 3/9] refactoring: MainKommi --- src/main/java/Notizbuch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Notizbuch.java b/src/main/java/Notizbuch.java index 3dfeb42..9d6423d 100644 --- a/src/main/java/Notizbuch.java +++ b/src/main/java/Notizbuch.java @@ -64,7 +64,7 @@ public class Notizbuch extends JFrame implements ActionListener { JOptionPane.showMessageDialog(this, "Fehler beim Laden der Notiz: " + e.getMessage()); } } - + // Hauptmethode zum Starten des Programms public static void main(String[] args) { SwingUtilities.invokeLater(() -> { Notizbuch notizbuch = new Notizbuch(); From 22ffef2d85651e2da1ae7aced33ed8fddfca20a7 Mon Sep 17 00:00:00 2001 From: Marc Dimmerling Date: Fri, 9 Feb 2024 19:56:58 +0100 Subject: [PATCH 4/9] refactoring: TextAreaKommi --- src/main/java/Notizbuch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Notizbuch.java b/src/main/java/Notizbuch.java index 9d6423d..10a12df 100644 --- a/src/main/java/Notizbuch.java +++ b/src/main/java/Notizbuch.java @@ -71,7 +71,7 @@ public class Notizbuch extends JFrame implements ActionListener { notizbuch.setVisible(true); }); } - + // Getter und Setter für die TextArea public JTextArea getTextArea() { return textArea; } From 07b3d048235906c2469cfaefbc9091388117a2ca Mon Sep 17 00:00:00 2001 From: Marc Dimmerling Date: Fri, 9 Feb 2024 19:58:42 +0100 Subject: [PATCH 5/9] refactoring: Notizbuch-FensterKommi --- src/main/java/Notizbuch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Notizbuch.java b/src/main/java/Notizbuch.java index 10a12df..4fbcd0a 100644 --- a/src/main/java/Notizbuch.java +++ b/src/main/java/Notizbuch.java @@ -68,7 +68,7 @@ public class Notizbuch extends JFrame implements ActionListener { public static void main(String[] args) { SwingUtilities.invokeLater(() -> { Notizbuch notizbuch = new Notizbuch(); - notizbuch.setVisible(true); + notizbuch.setVisible(true); // Das Notizbuch-Fenster anzeigen }); } // Getter und Setter für die TextArea From 41d8d067fe1db70c3ab101674e10e5b72c394d5a Mon Sep 17 00:00:00 2001 From: Marc Dimmerling Date: Fri, 9 Feb 2024 20:00:17 +0100 Subject: [PATCH 6/9] refactoring: noteTextappendKommi --- src/main/java/Notizbuch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Notizbuch.java b/src/main/java/Notizbuch.java index 4fbcd0a..88727c1 100644 --- a/src/main/java/Notizbuch.java +++ b/src/main/java/Notizbuch.java @@ -57,7 +57,7 @@ public class Notizbuch extends JFrame implements ActionListener { StringBuilder noteText = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { - noteText.append(line).append("\n"); + noteText.append(line).append("\n"); // Zeilen aus der Datei lesen und StringBuilder hinzufügen } getTextArea().setText(noteText.toString()); } catch (IOException e) { From 9393af3ce4b0637021898f7057f4f17d8bfae743 Mon Sep 17 00:00:00 2001 From: Marc Dimmerling Date: Fri, 9 Feb 2024 20:02:02 +0100 Subject: [PATCH 7/9] refactoring: ActionListenerKommi --- src/main/java/Notizbuch.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/Notizbuch.java b/src/main/java/Notizbuch.java index 88727c1..6734c84 100644 --- a/src/main/java/Notizbuch.java +++ b/src/main/java/Notizbuch.java @@ -35,6 +35,7 @@ public class Notizbuch extends JFrame implements ActionListener { @Override public void actionPerformed(ActionEvent e) { + // ActionListener-Methode für Button-Events if (e.getSource() == saveButton) { saveNote(); } else if (e.getSource() == loadButton) { From b503b46d9c349f6f5d7fd14f4d41810d7131a40f Mon Sep 17 00:00:00 2001 From: Marc Dimmerling Date: Fri, 9 Feb 2024 20:03:06 +0100 Subject: [PATCH 8/9] refactoring: SpeicherLadeButtonKommi --- src/main/java/Notizbuch.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/Notizbuch.java b/src/main/java/Notizbuch.java index 6734c84..3222f1b 100644 --- a/src/main/java/Notizbuch.java +++ b/src/main/java/Notizbuch.java @@ -20,7 +20,8 @@ public class Notizbuch extends JFrame implements ActionListener { setTextArea(new JTextArea()); add(new JScrollPane(getTextArea()), BorderLayout.CENTER); - + + // Erstellen der Speichern- und Laden-Buttons saveButton = new JButton("Speichern"); saveButton.addActionListener(this); loadButton = new JButton("Laden"); From 7ed1ec636edf194b4c5f859808832644b11118da Mon Sep 17 00:00:00 2001 From: Marc Dimmerling Date: Fri, 9 Feb 2024 20:04:12 +0100 Subject: [PATCH 9/9] =?UTF-8?q?refactoring:=20Panelsf=C3=BCrButtonKommi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/Notizbuch.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/Notizbuch.java b/src/main/java/Notizbuch.java index 3222f1b..2680ba3 100644 --- a/src/main/java/Notizbuch.java +++ b/src/main/java/Notizbuch.java @@ -26,7 +26,8 @@ public class Notizbuch extends JFrame implements ActionListener { saveButton.addActionListener(this); loadButton = new JButton("Laden"); loadButton.addActionListener(this); - + + // Erstellen eines Panels für die Buttons und Hinzufügen der Buttons JPanel buttonPanel = new JPanel(); buttonPanel.add(saveButton); buttonPanel.add(loadButton);