Hallo, hab ein (noch nicht ganz fertiges) prog,
nun ist es so, dass wen ich bei eclipse auf run gehe, wird alles richtig ausgeführt, wenn ich das als jar exportiere geht das loginfenster auf, aber das klick event beim button geht nicht mehr, es passsiert gar nix.
hier der zugehörige code:
nun ist es so, dass wen ich bei eclipse auf run gehe, wird alles richtig ausgeführt, wenn ich das als jar exportiere geht das loginfenster auf, aber das klick event beim button geht nicht mehr, es passsiert gar nix.
hier der zugehörige code:
Java:
public class LoginGui extends JFrame{
private static final long serialVersionUID = -7202608040306821255L;
private JButton okButton, okButton2, okButton3;
private JTextField nameFeld;
private JPasswordField pwdFeld;
public String loginname;
public Dialog failLogin;
public void getDesposed(){
this.setVisible(false);
}
LoginGui() {
super();
Container cp = getContentPane();
cp.setLayout(new GridLayout(5, 1));
okButton = new JButton("Login");
okButton.addActionListener( new LoginEvent());
pwdFeld = new JPasswordField();
JLabel UnameLabel = new JLabel("Benutzername:");
JLabel UpwdLabel = new JLabel("Passwort:");
nameFeld = new JTextField();
cp.add(UnameLabel);
cp.add(nameFeld);
cp.add(UpwdLabel);
cp.add(pwdFeld);
cp.add(okButton);
this.getRootPane().setDefaultButton(okButton);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setTitle("Login");
this.setResizable(false);
this.pack();
this.setSize(200, 180);
CenterGui.center(this);
}
class LoginEvent implements ActionListener {
public void actionPerformed(ActionEvent e) {
//werte aus der form in variablen abspeichern
loginname = nameFeld.getText();
char[] pwd = pwdFeld.getPassword();
String loginpwd = new String(pwd);
String rspwd = new String();
//passwort in md5 umwandlen
ZMS1 convertor = new ZMS1();
try{
loginpwd = convertor.verschMd5(loginpwd);
}
catch(Exception t){}
//verbindung zur datenbank herstellen und pw auslesen
hab ich ausgeschnitten
ResultSet rs = dbLogin.abfrage("SELECT `*****` FROM `******` WHERE `uname` LIKE '" + loginname + "'");
try {
if(rs.next()){
rspwd = rs.getString("upw");
//prüfen ob eingegebenes pw mit dem aus der db übereinstimmt
if(loginpwd.equalsIgnoreCase(rspwd) != true){
okButton3 = new JButton("OK");
okButton3.addActionListener( new DialogEvent());
JLabel dialogText = new JLabel("Das angegebene Passwort ist falsch!");
failLogin = new Dialog(LoginGui.this, "Login fail");
failLogin.setResizable(false);
failLogin.setSize(260, 100);
failLogin.setLayout(new FlowLayout());
failLogin.add(dialogText);
failLogin.add(okButton3);
CenterGui.center(failLogin);
okButton3.setSize(70, 30);
failLogin.setVisible(true);
}
else {
setVisible(false);
}
}
else{
okButton2 = new JButton("OK");
okButton2.addActionListener( new DialogEvent());
JLabel dialogText = new JLabel("Der angegebene Benutzername wurde nicht gefunden!");
failLogin = new Dialog(LoginGui.this, "Login fail");
failLogin.setResizable(false);
failLogin.setSize(370, 100);
failLogin.setLayout(new FlowLayout());
failLogin.add(dialogText);
failLogin.add(okButton2);
CenterGui.center(failLogin);
okButton2.setSize(70, 30);
failLogin.setVisible(true);
}
} catch (SQLException e1) {}
}
}