|
|
@ -13,7 +13,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
private static JPanel mainPanel = new JPanel(cl);
|
|
|
|
private static JPanel mainPanel = new JPanel(cl);
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
SwingUtilities.invokeLater(BibliothekGUI::new);
|
|
|
|
new BibliothekGUI();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public BibliothekGUI() {
|
|
|
|
public BibliothekGUI() {
|
|
|
@ -344,28 +344,21 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
private static void searchMenu(Kunde k) {
|
|
|
|
private static void searchMenu(Kunde k) {
|
|
|
|
JPanel mainSearch = new JPanel(new BorderLayout());
|
|
|
|
JPanel mainSearch = new JPanel(new BorderLayout());
|
|
|
|
//NORTH: Search bar
|
|
|
|
//NORTH: Search bar
|
|
|
|
JPanel enterSearch = new JPanel(new GridLayout(1,4,10,10));
|
|
|
|
JPanel enterSearch = new JPanel(new GridLayout(1,3,10,10));
|
|
|
|
JLabel text0 = new JLabel("Geben Sie einen Suchbegriff ein:");
|
|
|
|
JLabel text0 = new JLabel("Geben Sie einen Suchbegriff ein:");
|
|
|
|
JTextField enterSearchTerm = new JTextField(20);
|
|
|
|
JTextField enterSearchTerm = new JTextField(20);
|
|
|
|
JButton b0 = new JButton("Suchen");
|
|
|
|
//Hilfe von ChatGPT, da ich nicht wusste wie ich eine Checkbox hinzufüge und abhöre, ob
|
|
|
|
|
|
|
|
//sie gedrückt ist oder nicht box0.isSelected();)
|
|
|
|
JCheckBox box0 = new JCheckBox("Nur ausleihbare Medien anzeigen");
|
|
|
|
JCheckBox box0 = new JCheckBox("Nur ausleihbare Medien anzeigen");
|
|
|
|
enterSearch.add(text0);
|
|
|
|
enterSearch.add(text0);
|
|
|
|
enterSearch.add(enterSearchTerm);
|
|
|
|
enterSearch.add(enterSearchTerm);
|
|
|
|
enterSearch.add(b0);
|
|
|
|
|
|
|
|
enterSearch.add(box0);
|
|
|
|
enterSearch.add(box0);
|
|
|
|
mainSearch.add(enterSearch, BorderLayout.NORTH);
|
|
|
|
mainSearch.add(enterSearch, BorderLayout.NORTH);
|
|
|
|
//CENTER: Matched media
|
|
|
|
//CENTER: Matched media
|
|
|
|
mainSearch.revalidate();
|
|
|
|
mainSearch.revalidate();
|
|
|
|
int[] doThis = {0};
|
|
|
|
int[] doThis = {0};
|
|
|
|
box0.addActionListener(e -> {
|
|
|
|
box0.addActionListener(e -> {
|
|
|
|
if(box0.isSelected()) {
|
|
|
|
if(box0.isSelected() == true) {
|
|
|
|
doThis[0] = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
doThis[0] = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if(doThis[0] == 0) {
|
|
|
|
|
|
|
|
b0.addActionListener(e -> {
|
|
|
|
|
|
|
|
String searchTerm = enterSearchTerm.getText().toString();
|
|
|
|
String searchTerm = enterSearchTerm.getText().toString();
|
|
|
|
ArrayList<JLabel> matchedMedia = Bibliothek.findMatchesFiltered(searchTerm);
|
|
|
|
ArrayList<JLabel> matchedMedia = Bibliothek.findMatchesFiltered(searchTerm);
|
|
|
|
int i = matchedMedia.size();
|
|
|
|
int i = matchedMedia.size();
|
|
|
@ -374,6 +367,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
mainSearch.revalidate();
|
|
|
|
mainSearch.revalidate();
|
|
|
|
mainSearch.add(text1, BorderLayout.CENTER);
|
|
|
|
mainSearch.add(text1, BorderLayout.CENTER);
|
|
|
|
mainSearch.revalidate();
|
|
|
|
mainSearch.revalidate();
|
|
|
|
|
|
|
|
System.out.println("UNFIL");
|
|
|
|
} else if (i > 0){
|
|
|
|
} else if (i > 0){
|
|
|
|
JPanel ergebnisPanel = new JPanel(new GridLayout(i, 1, 10,10));
|
|
|
|
JPanel ergebnisPanel = new JPanel(new GridLayout(i, 1, 10,10));
|
|
|
|
for(JLabel j: matchedMedia) {
|
|
|
|
for(JLabel j: matchedMedia) {
|
|
|
@ -383,10 +377,10 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
mainSearch.add(ergebnisPanel, BorderLayout.CENTER);
|
|
|
|
mainSearch.add(ergebnisPanel, BorderLayout.CENTER);
|
|
|
|
mainSearch.revalidate();
|
|
|
|
mainSearch.revalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
mainSearch.revalidate();
|
|
|
|
|
|
|
|
doThis[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(doThis[0] == 1) {
|
|
|
|
else if(box0.isSelected() == false){
|
|
|
|
b0.addActionListener(e -> {
|
|
|
|
|
|
|
|
String searchTerm = enterSearchTerm.getText().toString();
|
|
|
|
String searchTerm = enterSearchTerm.getText().toString();
|
|
|
|
ArrayList<JLabel> matchedMedia = Bibliothek.findMatchesUnfiltered(searchTerm);
|
|
|
|
ArrayList<JLabel> matchedMedia = Bibliothek.findMatchesUnfiltered(searchTerm);
|
|
|
|
int i = matchedMedia.size();
|
|
|
|
int i = matchedMedia.size();
|
|
|
@ -395,6 +389,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
mainSearch.revalidate();
|
|
|
|
mainSearch.revalidate();
|
|
|
|
mainSearch.add(text1, BorderLayout.CENTER);
|
|
|
|
mainSearch.add(text1, BorderLayout.CENTER);
|
|
|
|
mainSearch.revalidate();
|
|
|
|
mainSearch.revalidate();
|
|
|
|
|
|
|
|
System.out.println("FIL");
|
|
|
|
} else if (i > 0){
|
|
|
|
} else if (i > 0){
|
|
|
|
JPanel ergebnisPanel = new JPanel(new GridLayout(i, 1, 10,10));
|
|
|
|
JPanel ergebnisPanel = new JPanel(new GridLayout(i, 1, 10,10));
|
|
|
|
for(JLabel j: matchedMedia) {
|
|
|
|
for(JLabel j: matchedMedia) {
|
|
|
@ -405,8 +400,10 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
mainSearch.revalidate();
|
|
|
|
mainSearch.revalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mainSearch.revalidate();
|
|
|
|
mainSearch.revalidate();
|
|
|
|
});
|
|
|
|
doThis[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
mainSearch.revalidate();
|
|
|
|
//SOUTH: OK Button to return
|
|
|
|
//SOUTH: OK Button to return
|
|
|
|
JButton b1 = new JButton("OK");
|
|
|
|
JButton b1 = new JButton("OK");
|
|
|
|
b1.addActionListener(e -> cl.show(mainPanel, "suchenMenu"));
|
|
|
|
b1.addActionListener(e -> cl.show(mainPanel, "suchenMenu"));
|
|
|
|