Zurück Button eingefügt

master
athar 2024-06-30 20:35:01 +02:00
parent d11cdf6f4c
commit 61c4f47588
1 changed files with 50 additions and 15 deletions

View File

@ -1,6 +1,5 @@
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -101,6 +100,10 @@ public class FakturamaGUI {
updateTextArea(); updateTextArea();
}); });
JButton backButton = new JButton("Zurück");
backButton.setBackground(new Color(255, 182, 193)); // Hellrot
backButton.addActionListener(e -> updateTextArea());
panel.add(nameLabel); panel.add(nameLabel);
panel.add(nameField); panel.add(nameField);
panel.add(addressLabel); panel.add(addressLabel);
@ -111,8 +114,8 @@ public class FakturamaGUI {
panel.add(taxExemptBox); panel.add(taxExemptBox);
panel.add(smallBusinessLabel); panel.add(smallBusinessLabel);
panel.add(smallBusinessBox); panel.add(smallBusinessBox);
panel.add(new JLabel());
panel.add(addButton); panel.add(addButton);
panel.add(backButton);
showPanel(panel); showPanel(panel);
} }
@ -139,6 +142,10 @@ public class FakturamaGUI {
updateTextArea(); updateTextArea();
}); });
JButton backButton = new JButton("Zurück");
backButton.setBackground(new Color(255, 182, 193)); // Hellrot
backButton.addActionListener(e -> updateTextArea());
panel.add(unitLabel); panel.add(unitLabel);
panel.add(unitField); panel.add(unitField);
panel.add(descriptionLabel); panel.add(descriptionLabel);
@ -147,8 +154,8 @@ public class FakturamaGUI {
panel.add(netPriceField); panel.add(netPriceField);
panel.add(vatRateLabel); panel.add(vatRateLabel);
panel.add(vatRateField); panel.add(vatRateField);
panel.add(new JLabel());
panel.add(addButton); panel.add(addButton);
panel.add(backButton);
showPanel(panel); showPanel(panel);
} }
@ -163,11 +170,6 @@ public class FakturamaGUI {
customerBox.addItem(customer.name); customerBox.addItem(customer.name);
} }
JLabel articlesLabel = new JLabel("Artikel:");
JList<String> 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:"); JLabel dateLabel = new JLabel("Datum:");
JTextField dateField = new JTextField(); JTextField dateField = new JTextField();
@ -176,6 +178,11 @@ public class FakturamaGUI {
formPanel.add(dateLabel); formPanel.add(dateLabel);
formPanel.add(dateField); formPanel.add(dateField);
JLabel articlesLabel = new JLabel("Artikel:");
JList<String> 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"); JButton addButton = new JButton("Erstellen");
addButton.setBackground(new Color(144, 238, 144)); // Hellgrün addButton.setBackground(new Color(144, 238, 144)); // Hellgrün
addButton.addActionListener(e -> { addButton.addActionListener(e -> {
@ -191,10 +198,18 @@ public class FakturamaGUI {
updateTextArea(); 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(formPanel, BorderLayout.NORTH);
panel.add(new JLabel("Artikel auswählen:"), BorderLayout.CENTER); panel.add(articlesLabel, BorderLayout.CENTER);
panel.add(articlesScrollPane, BorderLayout.CENTER); panel.add(articlesScrollPane, BorderLayout.CENTER);
panel.add(addButton, BorderLayout.SOUTH); panel.add(buttonPanel, BorderLayout.SOUTH);
showPanel(panel); showPanel(panel);
} }
@ -221,12 +236,16 @@ public class FakturamaGUI {
updateTextArea(); updateTextArea();
}); });
JButton backButton = new JButton("Zurück");
backButton.setBackground(new Color(255, 182, 193)); // Hellrot
backButton.addActionListener(e -> updateTextArea());
panel.add(offerLabel); panel.add(offerLabel);
panel.add(offerBox); panel.add(offerBox);
panel.add(dateLabel); panel.add(dateLabel);
panel.add(dateField); panel.add(dateField);
panel.add(new JLabel());
panel.add(addButton); panel.add(addButton);
panel.add(backButton);
showPanel(panel); showPanel(panel);
} }
@ -254,12 +273,16 @@ public class FakturamaGUI {
updateTextArea(); updateTextArea();
}); });
JButton backButton = new JButton("Zurück");
backButton.setBackground(new Color(255, 182, 193)); // Hellrot
backButton.addActionListener(e -> updateTextArea());
panel.add(orderConfirmationLabel); panel.add(orderConfirmationLabel);
panel.add(orderConfirmationBox); panel.add(orderConfirmationBox);
panel.add(dateLabel); panel.add(dateLabel);
panel.add(dateField); panel.add(dateField);
panel.add(new JLabel());
panel.add(addButton); panel.add(addButton);
panel.add(backButton);
showPanel(panel); showPanel(panel);
} }
@ -288,19 +311,30 @@ public class FakturamaGUI {
updateTextArea(); updateTextArea();
}); });
JButton backButton = new JButton("Zurück");
backButton.setBackground(new Color(255, 182, 193)); // Hellrot
backButton.addActionListener(e -> updateTextArea());
panel.add(deliveryNoteLabel); panel.add(deliveryNoteLabel);
panel.add(deliveryNoteBox); panel.add(deliveryNoteBox);
panel.add(dateLabel); panel.add(dateLabel);
panel.add(dateField); panel.add(dateField);
panel.add(new JLabel());
panel.add(addButton); panel.add(addButton);
panel.add(backButton);
showPanel(panel); showPanel(panel);
} }
private void showPanel(JPanel panel) { private void showPanel(JPanel panel) {
frame.getContentPane().removeAll(); 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.revalidate();
frame.repaint(); 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"); 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()); textArea.setText(sb.toString());
showPanel(new JScrollPane(textArea));
} }
public static void main(String[] args) { public static void main(String[] args) {