final commit of the day

dateFeature
Berat 2024-11-08 20:17:53 +01:00
parent 9d72491ed8
commit 82f37f745b
2 changed files with 49 additions and 3 deletions

View File

@ -1,6 +1,9 @@
package domainBib; package domainBib;
import java.awt.Component;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.JLabel;
import guiBib.*; import guiBib.*;
public class Bibliothek { public class Bibliothek {
@ -88,4 +91,24 @@ public class Bibliothek {
} }
return null; return null;
} }
public static int bücherLänge() {
return bücherListe.size();
}
public static ArrayList<JLabel> buchAuflisten() {
ArrayList<JLabel> jlabelList = new ArrayList<>();
for(Buch b: bücherListe) {
String titel = b.getTitel();
int jahr = b.getJahr();
String autor = b.getAutor();
int kennnummer = b.getKennnummer();
JLabel buch = new JLabel("Titel: " + titel
+ ", Autor: " + autor
+ ", Jahr: " + jahr
+ ", Kennnummer: " + kennnummer);
jlabelList.add(buch);
}
return jlabelList;
}
} }

View File

@ -4,6 +4,7 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList;
public class BibliothekGUI extends JFrame implements ActionListener{ public class BibliothekGUI extends JFrame implements ActionListener{
private static CardLayout cl = new CardLayout(); private static CardLayout cl = new CardLayout();
@ -39,12 +40,12 @@ public class BibliothekGUI extends JFrame implements ActionListener{
bp.add(b1); bp.add(b1);
bp.add(b2); bp.add(b2);
loginPanel.add(bp, BorderLayout.SOUTH); loginPanel.add(bp, BorderLayout.SOUTH);
mainPanel.add(loginPanel, "loginPanel");
cl.show(mainPanel, "loginPanel");
add(mainPanel); add(mainPanel);
setVisible(true); setVisible(true);
setSize(600, 600); setSize(600, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainPanel.add(loginPanel, "loginPanel");
cl.show(mainPanel, "loginPanel");
} }
public static void openAdmin() { public static void openAdmin() {
@ -85,7 +86,29 @@ public class BibliothekGUI extends JFrame implements ActionListener{
} }
private static void bookMenu() { private static void bookMenu() {
// TODO Auto-generated method stub int i = Bibliothek.bücherLänge();
if(i == 0) {
JPanel buchMenü = new JPanel(new BorderLayout());
JLabel text1 = new JLabel("Keine Bücher mehr vorhanden");
buchMenü.add(text1, BorderLayout.NORTH);
JButton b1 = new JButton("OK");
buchMenü.add(b1, BorderLayout.SOUTH);
mainPanel.add(buchMenü, "Bücher");
cl.show(mainPanel, "Bücher");
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
}
if(i != 0) {
JPanel buchMenü = new JPanel(new GridLayout(i+1, 2, 10, 10));
ArrayList<JLabel> jlabelList = Bibliothek.buchAuflisten();
for(JLabel j: jlabelList) {
buchMenü.add(j);
}
JButton b1 = new JButton("OK");
buchMenü.add(b1, BorderLayout.SOUTH);
mainPanel.add(buchMenü, "Bücher");
cl.show(mainPanel, "Bücher");
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
}
} }
private static void dvdMenu() { private static void dvdMenu() {