registerConfirmButton Action Listener implemented and fixed issue in getTextfieldContent()

gui
David Groys 2024-06-10 17:23:26 +02:00
parent 11db856157
commit 89c767f5c9
1 changed files with 17 additions and 4 deletions

View File

@ -340,9 +340,22 @@ public class Main extends JFrame {
registerConfirmButton.addActionListener(new ActionListener() { registerConfirmButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String nameTXT = getTextfieldContent(registerName, "registerNameText");
String passwordTXT = getTextfieldContent(registerPassword, "registerPasswordText");
String ortTXT = getTextfieldContent(registerName, "registerOrtText");
String plzTXT = getTextfieldContent(registerPassword, "registerPLZText");
String carNameTXT = getTextfieldContent(registerName, "registerCarNameText");
String carCO2TXT = getTextfieldContent(registerName, "registerCarCO2Text");
String carSpeedTXT = getTextfieldContent(registerPassword, "registerCarSpeedText");
String bikeSpeedTXT = getTextfieldContent(registerName, "registerBikeSpeedText");
if(sign_up_user(nameTXT, passwordTXT, ortTXT, plzTXT,
carNameTXT, carCO2TXT, carSpeedTXT, bikeSpeedTXT)){
cardLayout.show(panelLayout, "4"); cardLayout.show(panelLayout, "4");
jframe.setSize(new Dimension(500, 500)); jframe.setSize(new Dimension(500, 500));
// implementiere einlesen der textfelder des Panles }
else{
//mal gucken
}
} }
}); });
} }
@ -440,7 +453,7 @@ public class Main extends JFrame {
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())) {
return component.getText(); return ((JTextField) component).getText();
} }
} }
return null; return null;