diff --git a/PR2Bib/src/guiBib/BibliothekGUI.java b/PR2Bib/src/guiBib/BibliothekGUI.java index e1fc3ee..e7d8774 100644 --- a/PR2Bib/src/guiBib/BibliothekGUI.java +++ b/PR2Bib/src/guiBib/BibliothekGUI.java @@ -21,8 +21,20 @@ public class BibliothekGUI extends JFrame implements ActionListener{ JPanel loginPanel = new JPanel(new BorderLayout()); JLabel text1 = new JLabel("Login mit Kennnummer:"); loginPanel.add(text1, BorderLayout.NORTH); + JPanel loginGrid = new JPanel(new BorderLayout()); JTextField field1 = new JTextField(20); - loginPanel.add(field1, BorderLayout.CENTER); + loginGrid.add(field1); + loginPanel.add(loginGrid, BorderLayout.CENTER); + JButton b0 = new JButton("Registrieren"); + b0.addActionListener(e -> { nutzerAnlegen();}); + JButton b3 = new JButton("Ohne Anmeldung fortfahren"); + b3.addActionListener(e -> { + browseMedia(); + }); + JPanel buttonGrid = new JPanel(new GridLayout(1,2,10,10)); + buttonGrid.add(b0); + buttonGrid.add(b3); + loginGrid.add(buttonGrid, BorderLayout.SOUTH); JPanel bp = new JPanel(new GridLayout(1,2,10,10)); JButton b1 = new JButton("Abbrechen"); b1.addActionListener(e -> dispose()); @@ -48,6 +60,36 @@ public class BibliothekGUI extends JFrame implements ActionListener{ cl.show(mainPanel, "loginPanel"); } + private void browseMedia() { + JPanel browsePanel = new JPanel(new GridLayout(6, 1, 10, 10)); + JButton b1 = new JButton("Bücher"); + Kunde k = null; + b1.addActionListener(e -> bookMenu(k)); + JButton b2 = new JButton("DVDs"); + b2.addActionListener(e -> dvdMenu(k)); + JButton b3 = new JButton("CDs"); + b3.addActionListener(e -> cdMenu(k)); + JButton b4 = new JButton("Brettspiele"); + b4.addActionListener(e -> bsMenu(k)); + JButton b5 = new JButton("Videospiele"); + b5.addActionListener(e -> vsMenu(k)); + JButton b6 = new JButton("OK"); + b6.addActionListener(e -> cl.show(mainPanel, "loginPanel")); + browsePanel.add(b1); + browsePanel.add(b2); + browsePanel.add(b3); + browsePanel.add(b4); + browsePanel.add(b5); + browsePanel.add(b6); + mainPanel.add(browsePanel, "browsePanel"); + cl.show(mainPanel, "browsePanel"); + } + + private void nutzerAnlegen() { + // TODO Auto-generated method stub + + } + private static void openAdmin() { JPanel adminPanel = new JPanel(new BorderLayout()); JPanel adminGrid = new JPanel(new GridLayout(2, 1, 10, 10)); @@ -90,15 +132,15 @@ public class BibliothekGUI extends JFrame implements ActionListener{ JLabel text1 = new JLabel("Ihre Kennnnummer: " + k.getKennnummer()); mediumPanel.add(text1); JButton b1 = new JButton("Bücher"); - b1.addActionListener(e -> bookMenu()); + b1.addActionListener(e -> bookMenu(k)); JButton b2 = new JButton("DVDs"); - b2.addActionListener(e -> dvdMenu()); + b2.addActionListener(e -> dvdMenu(k)); JButton b3 = new JButton("CDs"); - b3.addActionListener(e -> cdMenu()); + b3.addActionListener(e -> cdMenu(k)); JButton b4 = new JButton("Brettspiele"); - b4.addActionListener(e -> bsMenu()); + b4.addActionListener(e -> bsMenu(k)); JButton b5 = new JButton("Videospiele"); - b5.addActionListener(e -> vsMenu()); + b5.addActionListener(e -> vsMenu(k)); JButton b6 = new JButton("Ausleihe"); b6.addActionListener(e -> ausleihenMenü(k)); JButton b7 = new JButton("Rückgabe"); @@ -220,7 +262,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{ cl.show(mainPanel, "Rückgabe"); } - private static void bookMenu() { + private static void bookMenu(Kunde k) { int i = Bibliothek.bücherLänge(); JPanel buchMenü = new JPanel(new GridLayout(i+2, 2, 10, 10)); JLabel text0 = new JLabel("Ausleihe für 4 Wochen, bis zu 3 Mal verlängerbar."); @@ -230,13 +272,18 @@ public class BibliothekGUI extends JFrame implements ActionListener{ buchMenü.add(j); } JButton b1 = new JButton("OK"); - b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel")); + b1.addActionListener(e -> { + if(k == null) { + cl.show(mainPanel, "browsePanel"); + } else { + cl.show(mainPanel, "mediumPanel");} + }); buchMenü.add(b1, BorderLayout.SOUTH); mainPanel.add(buchMenü, "Bücher"); cl.show(mainPanel, "Bücher"); } - private static void dvdMenu() { + private static void dvdMenu(Kunde k) { int i = Bibliothek.dvdLänge(); JPanel dvdMenü = new JPanel(new GridLayout(i+2, 2, 10, 10)); JLabel text0 = new JLabel("Ausleihe für 1 Woche, keine Verlängerung."); @@ -246,13 +293,18 @@ public class BibliothekGUI extends JFrame implements ActionListener{ dvdMenü.add(j); } JButton b1 = new JButton("OK"); - b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel")); + b1.addActionListener(e -> { + if(k == null) { + cl.show(mainPanel, "browsePanel"); + } else { + cl.show(mainPanel, "mediumPanel");} + }); dvdMenü.add(b1, BorderLayout.SOUTH); mainPanel.add(dvdMenü, "DVDs"); cl.show(mainPanel, "DVDs"); } - private static void cdMenu() { + private static void cdMenu(Kunde k) { int i = Bibliothek.cdLänge(); JPanel cdMenü = new JPanel(new GridLayout(i+2, 2, 10, 10)); JLabel text0 = new JLabel("Ausleihe für 2 Wochen, keine Verlängerung."); @@ -262,13 +314,17 @@ public class BibliothekGUI extends JFrame implements ActionListener{ cdMenü.add(j); } JButton b1 = new JButton("OK"); - b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel")); - cdMenü.add(b1, BorderLayout.SOUTH); + b1.addActionListener(e -> { + if(k == null) { + cl.show(mainPanel, "browsePanel"); + } else { + cl.show(mainPanel, "mediumPanel");} + }); cdMenü.add(b1, BorderLayout.SOUTH); mainPanel.add(cdMenü, "CDs"); cl.show(mainPanel, "CDs"); } - private static void bsMenu() { + private static void bsMenu(Kunde k) { int i = Bibliothek.bsLänge(); JPanel bsMenü = new JPanel(new GridLayout(i+2, 2, 10, 10)); JLabel text0 = new JLabel("Ausleihe für 2 Wochen, keine Verlängerung."); @@ -278,13 +334,17 @@ public class BibliothekGUI extends JFrame implements ActionListener{ bsMenü.add(j); } JButton b1 = new JButton("OK"); - b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel")); - bsMenü.add(b1, BorderLayout.SOUTH); + b1.addActionListener(e -> { + if(k == null) { + cl.show(mainPanel, "browsePanel"); + } else { + cl.show(mainPanel, "mediumPanel");} + }); bsMenü.add(b1, BorderLayout.SOUTH); mainPanel.add(bsMenü, "Brettspiele"); cl.show(mainPanel, "Brettspiele"); } - private static void vsMenu() { + private static void vsMenu(Kunde k) { int i = Bibliothek.vsLänge(); JPanel vsMenü = new JPanel(new GridLayout(i+2, 2, 10, 10)); JLabel text0 = new JLabel("Ausleihe für 4 Wochen, einmalige Verlängerung möglich."); @@ -294,8 +354,12 @@ public class BibliothekGUI extends JFrame implements ActionListener{ vsMenü.add(j); } JButton b1 = new JButton("OK"); - b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel")); - vsMenü.add(b1, BorderLayout.SOUTH); + b1.addActionListener(e -> { + if(k == null) { + cl.show(mainPanel, "browsePanel"); + } else { + cl.show(mainPanel, "mediumPanel");} + }); vsMenü.add(b1, BorderLayout.SOUTH); mainPanel.add(vsMenü, "Videospiele"); cl.show(mainPanel, "Videospiele"); }