implemented scrollbar with search results with error message if none are found
parent
5eaff1161b
commit
1a45bc23ec
|
@ -59,7 +59,7 @@ public class Main extends JFrame {
|
||||||
private JButton changePasswordButton;
|
private JButton changePasswordButton;
|
||||||
private JButton changeDetailsButton;
|
private JButton changeDetailsButton;
|
||||||
private JButton logOutButton;
|
private JButton logOutButton;
|
||||||
private JScrollPane jsp = new JScrollPane();
|
private JScrollPane jsp;
|
||||||
private JPanel destinationButtons = new JPanel();
|
private JPanel destinationButtons = new JPanel();
|
||||||
|
|
||||||
private JPanel changePassword;
|
private JPanel changePassword;
|
||||||
|
@ -154,7 +154,6 @@ public class Main extends JFrame {
|
||||||
logOutButtonCreate();
|
logOutButtonCreate();
|
||||||
changeDetailsButtonCreate();
|
changeDetailsButtonCreate();
|
||||||
changePasswordButtonCreate();
|
changePasswordButtonCreate();
|
||||||
jsp.add(destinationButtons);
|
|
||||||
menuLabel.setBounds(180, -125, 300, 300);
|
menuLabel.setBounds(180, -125, 300, 300);
|
||||||
searchPLZ_ORT.setBounds(20, 50, 300, 100);
|
searchPLZ_ORT.setBounds(20, 50, 300, 100);
|
||||||
searchConfirmButton.setBounds(346, 70, 110, 30);
|
searchConfirmButton.setBounds(346, 70, 110, 30);
|
||||||
|
@ -163,7 +162,6 @@ public class Main extends JFrame {
|
||||||
logOutButton.setBounds(340, 430, 130, 30);
|
logOutButton.setBounds(340, 430, 130, 30);
|
||||||
changeDetailsButton.setBounds(340, 398, 130, 30);
|
changeDetailsButton.setBounds(340, 398, 130, 30);
|
||||||
changePasswordButton.setBounds(340, 366, 130, 30);
|
changePasswordButton.setBounds(340, 366, 130, 30);
|
||||||
jsp.setBounds(50,50,300,400);
|
|
||||||
|
|
||||||
menu.add(menuLabel);
|
menu.add(menuLabel);
|
||||||
menu.add(searchPLZ_ORT);
|
menu.add(searchPLZ_ORT);
|
||||||
|
@ -522,18 +520,21 @@ public class Main extends JFrame {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
ArrayList<String> orte = facade.search(getTextfieldContent(searchPLZ_ORT, "ortSuche"));
|
ArrayList<String> orte = facade.search(getTextfieldContent(searchPLZ_ORT, "ortSuche"));
|
||||||
JPanel destinationButtonsProxy = new JPanel(new FlowLayout());
|
JPanel destinationButtonsProxy = new JPanel();
|
||||||
|
destinationButtonsProxy.setLayout(new BoxLayout(destinationButtonsProxy, BoxLayout.Y_AXIS));
|
||||||
|
if (orte.size() > 0) {
|
||||||
for (String s : orte) {
|
for (String s : orte) {
|
||||||
String[] ortUndPLZ = s.split(";");
|
String[] ortUndPLZ = s.split(";");
|
||||||
String address = ortUndPLZ[1] + ", " + ortUndPLZ[0];
|
String plz = ortUndPLZ[0];
|
||||||
|
String address = ortUndPLZ[1] + "," + plz + " " + facade.distance(plz);
|
||||||
JButton jb = new JButton(address);
|
JButton jb = new JButton(address);
|
||||||
jb.setSize(100,20);
|
jb.setPreferredSize(new Dimension(290, 40));
|
||||||
jb.addActionListener(new ActionListener() {
|
jb.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
JFrame jf = new JFrame();
|
JFrame jf = new JFrame();
|
||||||
JPanel jp = new JPanel(new FlowLayout());
|
JPanel jp = new JPanel(new FlowLayout());
|
||||||
String[] details = facade.destination_details(ortUndPLZ[0]);
|
String[] details = facade.destination_details(plz);
|
||||||
for (String ss : details) {
|
for (String ss : details) {
|
||||||
JLabel jl = new JLabel(ss);
|
JLabel jl = new JLabel(ss);
|
||||||
jp.add(jl);
|
jp.add(jl);
|
||||||
|
@ -541,16 +542,51 @@ public class Main extends JFrame {
|
||||||
jf.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
jf.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
jf.add(jp);
|
jf.add(jp);
|
||||||
jf.setSize(100, 400);
|
jf.setSize(100, 400);
|
||||||
|
jf.setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//erzeuge aus adresse einen Button
|
destinationButtonsProxy.add(jb);
|
||||||
}
|
}
|
||||||
destinationButtons = destinationButtonsProxy;
|
destinationButtons = destinationButtonsProxy;
|
||||||
|
destinationButtons.revalidate();
|
||||||
|
destinationButtons.repaint();
|
||||||
|
try {
|
||||||
|
menu.remove(jsp);
|
||||||
|
} catch (Exception jspNotYetIncluded) {
|
||||||
|
}
|
||||||
|
jsp = new JScrollPane(destinationButtons);
|
||||||
|
jsp.setBounds(40, 110, 244, 336);
|
||||||
|
jsp.revalidate();
|
||||||
|
jsp.repaint();
|
||||||
|
menu.add(jsp);
|
||||||
menu.revalidate();
|
menu.revalidate();
|
||||||
|
menu.repaint();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
destinationButtonsProxy = new JPanel();
|
||||||
|
JLabel jl = new JLabel("Kein Ergebnis");
|
||||||
|
jl.setFont(new Font("Arial", Font.PLAIN, 38));
|
||||||
|
destinationButtonsProxy.add(jl);
|
||||||
|
destinationButtons = destinationButtonsProxy;
|
||||||
|
destinationButtons.revalidate();
|
||||||
|
destinationButtons.repaint();
|
||||||
|
try {
|
||||||
|
menu.remove(jsp);
|
||||||
|
} catch (Exception jspNotYetIncluded) {
|
||||||
|
}
|
||||||
|
jsp = new JScrollPane(destinationButtons);
|
||||||
|
jsp.setBounds(40, 110, 244, 336);
|
||||||
|
jsp.revalidate();
|
||||||
|
jsp.repaint();
|
||||||
|
menu.add(jsp);
|
||||||
|
menu.revalidate();
|
||||||
|
menu.repaint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void randDestinationsCarButtonCreate() { //Auto Icon hinzufügen
|
private void randDestinationsCarButtonCreate() { //Auto Icon hinzufügen
|
||||||
randDestinationsCarButton = new JButton();
|
randDestinationsCarButton = new JButton();
|
||||||
randDestinationsCarButton.setPreferredSize(new Dimension(150, 80));
|
randDestinationsCarButton.setPreferredSize(new Dimension(150, 80));
|
||||||
|
@ -807,6 +843,12 @@ public class Main extends JFrame {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void jspCreate(){
|
||||||
|
jsp = new JScrollPane();
|
||||||
|
jsp.setSize(100,100);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private String getTextfieldContent(JPanel panel, String name) {
|
private String getTextfieldContent(JPanel panel, String name) {
|
||||||
for (Component component : panel.getComponents()) {
|
for (Component component : panel.getComponents()) {
|
||||||
if (component instanceof JTextField && name.equals(component.getName())) {
|
if (component instanceof JTextField && name.equals(component.getName())) {
|
||||||
|
|
Loading…
Reference in New Issue