loginConfirmButton Action Listener implemented

gui
David Groys 2024-06-10 17:04:57 +02:00
parent 9bdae273d8
commit 11db856157
1 changed files with 35 additions and 20 deletions

View File

@ -189,7 +189,7 @@ public class Main extends JFrame {
public void actionPerformed(ActionEvent e) {
cardLayout.show(panelLayout, "2");
jframe.setSize(new Dimension(400, 150));
// implementiere einlesen der textfelder des Panels
// implementiere einlesen der textfelder des Panles
}
});
@ -234,9 +234,15 @@ public class Main extends JFrame {
loginConfirmButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String nameTXT = getTextfieldContent(loginName, "loginNameText");
String passwordTXT = getTextfieldContent(loginPassword, "loginPasswordText");
if(facade.sign_in_user(nameTXT, passwordTXT)) {
cardLayout.show(panelLayout, "4");
jframe.setSize(new Dimension(500, 500));
// implementiere einlesen der textfelder des Panles
}
else{
//vllt zukünftig implementiert
}
}
});
}
@ -431,6 +437,15 @@ public class Main extends JFrame {
});
}
private String getTextfieldContent(JPanel panel, String name) {
for (Component component : panel.getComponents()) {
if (component instanceof JTextField && name.equals(component.getName())) {
return component.getText();
}
}
return null;
}
public ImageIcon png(String path, int sizeX, int sizeY) { // umständlich und png nicht transparent
ImageIcon icon = new ImageIcon(getClass().getResource(path)); // Path des PNGs muss angegeben werden
Image img = icon.getImage();