From 61c4f47588e2be2086d5a9f5de823df074e6086b Mon Sep 17 00:00:00 2001 From: athar Date: Sun, 30 Jun 2024 20:35:01 +0200 Subject: [PATCH] =?UTF-8?q?Zur=C3=BCck=20Button=20eingef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PR2 KI Projekt/src/FakturamaGUI.java | 65 +++++++++++++++++++++------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/PR2 KI Projekt/src/FakturamaGUI.java b/PR2 KI Projekt/src/FakturamaGUI.java index 89cc3c6..13f1b6e 100644 --- a/PR2 KI Projekt/src/FakturamaGUI.java +++ b/PR2 KI Projekt/src/FakturamaGUI.java @@ -1,6 +1,5 @@ import javax.swing.*; import java.awt.*; -import java.awt.event.*; import java.util.ArrayList; import java.util.List; @@ -101,6 +100,10 @@ public class FakturamaGUI { updateTextArea(); }); + JButton backButton = new JButton("Zurück"); + backButton.setBackground(new Color(255, 182, 193)); // Hellrot + backButton.addActionListener(e -> updateTextArea()); + panel.add(nameLabel); panel.add(nameField); panel.add(addressLabel); @@ -111,8 +114,8 @@ public class FakturamaGUI { panel.add(taxExemptBox); panel.add(smallBusinessLabel); panel.add(smallBusinessBox); - panel.add(new JLabel()); panel.add(addButton); + panel.add(backButton); showPanel(panel); } @@ -139,6 +142,10 @@ public class FakturamaGUI { updateTextArea(); }); + JButton backButton = new JButton("Zurück"); + backButton.setBackground(new Color(255, 182, 193)); // Hellrot + backButton.addActionListener(e -> updateTextArea()); + panel.add(unitLabel); panel.add(unitField); panel.add(descriptionLabel); @@ -147,8 +154,8 @@ public class FakturamaGUI { panel.add(netPriceField); panel.add(vatRateLabel); panel.add(vatRateField); - panel.add(new JLabel()); panel.add(addButton); + panel.add(backButton); showPanel(panel); } @@ -156,18 +163,13 @@ public class FakturamaGUI { private void showCreateOfferPanel() { JPanel panel = new JPanel(new BorderLayout()); JPanel formPanel = new JPanel(new GridLayout(4, 2)); - + JLabel customerLabel = new JLabel("Kunde:"); JComboBox customerBox = new JComboBox<>(); for (Main.Customer customer : Main.customers) { customerBox.addItem(customer.name); } - JLabel articlesLabel = new JLabel("Artikel:"); - JList articlesList = new JList<>(Main.articles.stream().map(a -> a.description).toArray(String[]::new)); - articlesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - JScrollPane articlesScrollPane = new JScrollPane(articlesList); - JLabel dateLabel = new JLabel("Datum:"); JTextField dateField = new JTextField(); @@ -176,6 +178,11 @@ public class FakturamaGUI { formPanel.add(dateLabel); formPanel.add(dateField); + JLabel articlesLabel = new JLabel("Artikel:"); + JList articlesList = new JList<>(Main.articles.stream().map(a -> a.description).toArray(String[]::new)); + articlesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + JScrollPane articlesScrollPane = new JScrollPane(articlesList); + JButton addButton = new JButton("Erstellen"); addButton.setBackground(new Color(144, 238, 144)); // Hellgrün addButton.addActionListener(e -> { @@ -191,10 +198,18 @@ public class FakturamaGUI { updateTextArea(); }); + JButton backButton = new JButton("Zurück"); + backButton.setBackground(new Color(255, 182, 193)); // Hellrot + backButton.addActionListener(e -> updateTextArea()); + + JPanel buttonPanel = new JPanel(new GridLayout(1, 2)); + buttonPanel.add(addButton); + buttonPanel.add(backButton); + panel.add(formPanel, BorderLayout.NORTH); - panel.add(new JLabel("Artikel auswählen:"), BorderLayout.CENTER); + panel.add(articlesLabel, BorderLayout.CENTER); panel.add(articlesScrollPane, BorderLayout.CENTER); - panel.add(addButton, BorderLayout.SOUTH); + panel.add(buttonPanel, BorderLayout.SOUTH); showPanel(panel); } @@ -221,12 +236,16 @@ public class FakturamaGUI { updateTextArea(); }); + JButton backButton = new JButton("Zurück"); + backButton.setBackground(new Color(255, 182, 193)); // Hellrot + backButton.addActionListener(e -> updateTextArea()); + panel.add(offerLabel); panel.add(offerBox); panel.add(dateLabel); panel.add(dateField); - panel.add(new JLabel()); panel.add(addButton); + panel.add(backButton); showPanel(panel); } @@ -254,12 +273,16 @@ public class FakturamaGUI { updateTextArea(); }); + JButton backButton = new JButton("Zurück"); + backButton.setBackground(new Color(255, 182, 193)); // Hellrot + backButton.addActionListener(e -> updateTextArea()); + panel.add(orderConfirmationLabel); panel.add(orderConfirmationBox); panel.add(dateLabel); panel.add(dateField); - panel.add(new JLabel()); panel.add(addButton); + panel.add(backButton); showPanel(panel); } @@ -288,19 +311,30 @@ public class FakturamaGUI { updateTextArea(); }); + JButton backButton = new JButton("Zurück"); + backButton.setBackground(new Color(255, 182, 193)); // Hellrot + backButton.addActionListener(e -> updateTextArea()); + panel.add(deliveryNoteLabel); panel.add(deliveryNoteBox); panel.add(dateLabel); panel.add(dateField); - panel.add(new JLabel()); panel.add(addButton); + panel.add(backButton); showPanel(panel); } private void showPanel(JPanel panel) { frame.getContentPane().removeAll(); - frame.getContentPane().add(panel, BorderLayout.NORTH); + frame.getContentPane().add(panel, BorderLayout.CENTER); + frame.revalidate(); + frame.repaint(); + } + + private void showPanel(JScrollPane scrollPane) { + frame.getContentPane().removeAll(); + frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.revalidate(); frame.repaint(); } @@ -335,6 +369,7 @@ public class FakturamaGUI { sb.append("Rechnung #").append(invoice.id).append(" - ").append(invoice.deliveryNote.orderConfirmation.offer.customer.name).append(" - ").append(invoice.date).append(" - ").append(invoice.status).append("\n"); } textArea.setText(sb.toString()); + showPanel(new JScrollPane(textArea)); } public static void main(String[] args) {