Hallo liebe Community,
ich habe ein kleines Programm geschrieben, nun ist mein Problem, dass wenn ich mich einlogge und wieder abmelde, das abfangen von falschen Nutzerdaten nicht mehr funktioniert. Hilfe ???:L:rtfm:
ich habe ein kleines Programm geschrieben, nun ist mein Problem, dass wenn ich mich einlogge und wieder abmelde, das abfangen von falschen Nutzerdaten nicht mehr funktioniert. Hilfe ???:L:rtfm:
Java:
package GUI;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.ImageIcon;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JPasswordField;
import javax.swing.JTextPane;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
public class Login_frame extends JFrame {
//Variablen
private JPanel contentPane;
private JPasswordField txtpassword;
ImageIcon icon;
static Login_frame frame;
static boolean access=false,access1=false;
static int falsepwcounter=4,counter=0,usercounter=1;
static String newuser;
static int newpassword;
public static void main(String[] args) {
Benutzer.setAdmin();
Benutzer.setUsers();
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame = new Login_frame();
frame.setLocationRelativeTo(null);
frame.setTitle("Mini ERP - Login");
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Frame
*/
public Login_frame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblLoginBereich = new JLabel("Snackalicious Login");
lblLoginBereich.setFont(new Font("Yaquote Script Personal Use", Font.PLAIN, 45));
lblLoginBereich.setIcon(null);
lblLoginBereich.setToolTipText("");
lblLoginBereich.setBounds(99, 0, 325, 83);
contentPane.add(lblLoginBereich);
final JTextArea txtuser = new JTextArea();
txtuser.setBounds(237, 72, 61, 22);
contentPane.add(txtuser);
txtpassword = new JPasswordField();
txtpassword.setBounds(237, 105, 63, 20);
contentPane.add(txtpassword);
JLabel lblBenutzer = new JLabel("Benutzer:");
lblBenutzer.setToolTipText("");
lblBenutzer.setFont(new Font("Arial Black", Font.PLAIN, 13));
lblBenutzer.setBounds(142, 71, 75, 22);
contentPane.add(lblBenutzer);
JLabel lblPasswort = new JLabel("Passwort:");
lblPasswort.setToolTipText("");
lblPasswort.setFont(new Font("Arial Black", Font.PLAIN, 13));
lblPasswort.setBounds(142, 102, 75, 22);
contentPane.add(lblPasswort);
JButton btnLogin = new JButton("Login");
btnLogin.addActionListener(new ActionListener() {
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent arg0) {
counter=0;
falsepwcounter=4;
do {
if (txtuser.getText().toLowerCase().equals(Benutzer.user[counter]) && Integer.parseInt(txtpassword.getText())==Benutzer.password[counter])
{access=true;JOptionPane.showMessageDialog(null,"Anmeldung erfolgreich!");menu.main(null);frame.setVisible(false);}
if (counter==Benutzer.user.length-1)
{JOptionPane.showMessageDialog(null,"Benutzername oder Passwort falsch!\n Noch "+(falsepwcounter-1)+" Versuche verbleibend!");falsepwcounter--;frame.setVisible(false);Login_frame.main(null);}
if (falsepwcounter==0){System.exit(0);}
counter++;
}while(access==false);
}
});
btnLogin.setBounds(222, 136, 89, 23);
contentPane.add(btnLogin);
JLabel lblNewLabel = new JLabel("by Dennis Dierkes");
lblNewLabel.setFont(new Font("Yaquote Script Personal Use", Font.PLAIN, 30));
lblNewLabel.setBounds(285, 225, 174, 40);
contentPane.add(lblNewLabel);
}
}
Java:
package GUI;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextPane;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import java.awt.Choice;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import javax.swing.ImageIcon;
import java.awt.Font;
import javax.swing.JToolBar;
import javax.swing.JMenuBar;
import javax.swing.JPopupMenu;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class menu extends JFrame {
SimpleDateFormat l = new SimpleDateFormat("hh:mm:ss");
Timestamp time=new Timestamp(System.currentTimeMillis());
String time1;
static menu frame;
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame = new menu();
frame.setLocationRelativeTo(null);
frame.setTitle("Mini ERP - Menü");
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public menu() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 711, 506);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblAngemeldetAls = new JLabel("Angemeldet als: "+Benutzer.user[Login_frame.counter]);
lblAngemeldetAls.setBounds(10, 11, 142, 14);
contentPane.add(lblAngemeldetAls);
JButton btnZugngeRegistrieren = new JButton("Verkauf");
btnZugngeRegistrieren.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
sell.main(null);
}
});
btnZugngeRegistrieren.setBounds(232, 62, 255, 52);
contentPane.add(btnZugngeRegistrieren);
JButton btnEinkauf = new JButton("Einkauf");
btnEinkauf.setBounds(232, 130, 255, 52);
contentPane.add(btnEinkauf);
JButton btnLagerbestand = new JButton("Lagerbestand");
btnLagerbestand.setBounds(232, 199, 255, 52);
contentPane.add(btnLagerbestand);
JButton btnAbrechnung = new JButton("Abrechnung");
btnAbrechnung.setBounds(232, 272, 255, 52);
contentPane.add(btnAbrechnung);
JLabel label = new JLabel("Angemeldet seit: "+l.format(time));
label.setBounds(10, 33, 160, 14);
contentPane.add(label);
JLabel label_1 = new JLabel("");
label_1.setIcon(new ImageIcon("E:\\Workspace Eclipse\\Simple ERP\\src\\GUI\\toast.png"));
label_1.setBounds(567, 0, 143, 114);
contentPane.add(label_1);
JLabel lblSnackalicious = new JLabel("Snackalicious");
lblSnackalicious.setFont(new Font("Yaquote Script Personal Use", Font.PLAIN, 80));
lblSnackalicious.setBounds(228, 335, 381, 94);
contentPane.add(lblSnackalicious);
JLabel lblNewLabel = new JLabel("by Dennis Dierkes");
lblNewLabel.setFont(new Font("Yaquote Script Personal Use", Font.PLAIN, 30));
lblNewLabel.setBounds(537, 428, 174, 40);
contentPane.add(lblNewLabel);
JButton btnSpeichern = new JButton("Speichern");
btnSpeichern.setBounds(10, 52, 128, 23);
contentPane.add(btnSpeichern);
JButton btnLaden = new JButton("Laden");
btnLaden.setBounds(10, 77, 128, 23);
contentPane.add(btnLaden);
JButton btnAbmelden = new JButton("Abmelden");
btnAbmelden.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//AUTOSAVE!
Login_frame.main(null);
frame.dispose();
}
});
btnAbmelden.setBounds(10, 122, 128, 23);
contentPane.add(btnAbmelden);
if (Login_frame.counter==0){
JButton btnNewButton = new JButton("Zur\u00FCcksetzen");
btnNewButton.setBounds(10, 145, 128, 23);
contentPane.add(btnNewButton);
}
}
}
Java:
package GUI;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Menu;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.GridLayout;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.AbstractListModel;
import javax.swing.border.BevelBorder;
import java.awt.Font;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class sell extends JFrame {
SimpleDateFormat l = new SimpleDateFormat("hh:mm:ss");
Timestamp time=new Timestamp(System.currentTimeMillis());
String time1;
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;
private JTextField textField_4;
private JTextField textField_5;
private JTextField textField_6;
private JTextField textField_7;
private JTextField textField_8;
private JTextField textField_9;
private JTextField textField_10;
private JTextField textField_11;
private JTextField textField_12;
private JTextField textField_13;
private JTextField textField_14;
private JTextField textField_15;
private JTextField textField_16;
private JTextField textField_17;
static sell frame ;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame = new sell();
frame.setLocationRelativeTo(null);
frame.setTitle("Mini ERP - Verkauf");
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public sell() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 711, 506);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel label_1 = new JLabel("");
label_1.setIcon(new ImageIcon("E:\\Workspace Eclipse\\Simple ERP\\src\\GUI\\toast.png"));
label_1.setBounds(567, 0, 143, 114);
contentPane.add(label_1);
JLabel lblAngemeldetAls = new JLabel("Angemeldet als: "+Benutzer.user[Login_frame.counter]);
lblAngemeldetAls.setBounds(10, 11, 142, 14);
contentPane.add(lblAngemeldetAls);
JLabel lblAngemeldetSeit = new JLabel("Angemeldet seit: "+l.format(time));
lblAngemeldetSeit.setBounds(10, 30, 160, 14);
contentPane.add(lblAngemeldetSeit);
JLabel lblNewLabel = new JLabel("S\u00FC\u00DFigkeiten");
lblNewLabel.setFont(new Font("Yaquote Script Personal Use", Font.PLAIN, 32));
lblNewLabel.setBounds(155, 66, 151, 41);
contentPane.add(lblNewLabel);
JLabel lblGetrnke = new JLabel("Getr\u00E4nke");
lblGetrnke.setFont(new Font("Yaquote Script Personal Use", Font.PLAIN, 33));
lblGetrnke.setBounds(305, 66, 122, 40);
contentPane.add(lblGetrnke);
JLabel lblHerzhaftes = new JLabel("Herzhaftes");
lblHerzhaftes.setFont(new Font("Yaquote Script Personal Use", Font.PLAIN, 33));
lblHerzhaftes.setBounds(461, 69, 114, 34);
contentPane.add(lblHerzhaftes);
JLabel label = new JLabel("__________________________________________________________________");
label.setBounds(155, 83, 479, 14);
contentPane.add(label);
JLabel lblNewLabel1 = new JLabel("by Dennis Dierkes");
lblNewLabel1.setFont(new Font("Yaquote Script Personal Use", Font.PLAIN, 30));
lblNewLabel1.setBounds(537, 428, 174, 40);
contentPane.add(lblNewLabel1);
JLabel lblSnackalicious = new JLabel("Snackalicious");
lblSnackalicious.setFont(new Font("Yaquote Script Personal Use", Font.PLAIN, 80));
lblSnackalicious.setBounds(228, 335, 381, 94);
contentPane.add(lblSnackalicious);
JList list = new JList();
list.setToolTipText("1\t\r\n2\r\n3\r\n4\r\n");
list.setBounds(246, 118, -80, 34);
contentPane.add(list);
JComboBox comboBox = new JComboBox();
comboBox.setModel(new DefaultComboBoxModel(new String[] {"-", "Duplo", "Kinder Bueno", "Kinder Riegel", "Kinderpingui", "Kit Kat", "Knoppers", "Maxi King", "Milchschnitte", "Nic Nacs", "Pick UP!", "Snickers ", "Twix"}));
comboBox.setBounds(155, 118, 97, 20);
contentPane.add(comboBox);
textField = new JTextField();
textField.setBounds(257, 118, 35, 20);
contentPane.add(textField);
textField.setColumns(10);
JComboBox comboBox_1 = new JComboBox();
comboBox_1.setModel(new DefaultComboBoxModel(new String[] {"-", "Duplo", "Kinder Bueno", "Kinder Riegel", "Kinderpingui", "Kit Kat", "Knoppers", "Maxi King", "Milchschnitte", "Nic Nacs", "Pick UP!", "Snickers ", "Twix"}));
comboBox_1.setBounds(155, 149, 97, 20);
String eins = (String) comboBox_1.getSelectedItem();
contentPane.add(comboBox_1);
JComboBox comboBox_2 = new JComboBox();
comboBox_2.setModel(new DefaultComboBoxModel(new String[] {"-", "Duplo", "Kinder Bueno", "Kinder Riegel", "Kinderpingui", "Kit Kat", "Knoppers", "Maxi King", "Milchschnitte", "Nic Nacs", "Pick UP!", "Snickers ", "Twix"}));
comboBox_2.setBounds(155, 184, 97, 20);
contentPane.add(comboBox_2);
JComboBox comboBox_3 = new JComboBox();
comboBox_3.setModel(new DefaultComboBoxModel(new String[] {"-", "Duplo", "Kinder Bueno", "Kinder Riegel", "Kinderpingui", "Kit Kat", "Knoppers", "Maxi King", "Milchschnitte", "Nic Nacs", "Pick UP!", "Snickers ", "Twix"}));
comboBox_3.setBounds(155, 215, 97, 20);
contentPane.add(comboBox_3);
JComboBox comboBox_4 = new JComboBox();
comboBox_4.setModel(new DefaultComboBoxModel(new String[] {"-", "Duplo", "Kinder Bueno", "Kinder Riegel", "Kinderpingui", "Kit Kat", "Knoppers", "Maxi King", "Milchschnitte", "Nic Nacs", "Pick UP!", "Snickers ", "Twix"}));
comboBox_4.setBounds(155, 251, 97, 20);
contentPane.add(comboBox_4);
JComboBox comboBox_5 = new JComboBox();
comboBox_5.setModel(new DefaultComboBoxModel(new String[] {"-", "Duplo", "Kinder Bueno", "Kinder Riegel", "Kinderpingui", "Kit Kat", "Knoppers", "Maxi King", "Milchschnitte", "Nic Nacs", "Pick UP!", "Snickers ", "Twix"}));
comboBox_5.setBounds(155, 282, 97, 20);
contentPane.add(comboBox_5);
textField_1 = new JTextField();
textField_1.setColumns(10);
textField_1.setBounds(257, 149, 35, 20);
contentPane.add(textField_1);
textField_2 = new JTextField();
textField_2.setColumns(10);
textField_2.setBounds(257, 184, 35, 20);
contentPane.add(textField_2);
textField_3 = new JTextField();
textField_3.setColumns(10);
textField_3.setBounds(257, 215, 35, 20);
contentPane.add(textField_3);
textField_4 = new JTextField();
textField_4.setColumns(10);
textField_4.setBounds(257, 251, 35, 20);
contentPane.add(textField_4);
textField_5 = new JTextField();
textField_5.setColumns(10);
textField_5.setBounds(257, 282, 35, 20);
contentPane.add(textField_5);
JComboBox comboBox_6 = new JComboBox();
comboBox_6.setBounds(305, 118, 97, 20);
contentPane.add(comboBox_6);
textField_6 = new JTextField();
textField_6.setColumns(10);
textField_6.setBounds(405, 118, 35, 20);
contentPane.add(textField_6);
JComboBox comboBox_7 = new JComboBox();
comboBox_7.setBounds(461, 118, 97, 20);
contentPane.add(comboBox_7);
textField_7 = new JTextField();
textField_7.setColumns(10);
textField_7.setBounds(560, 118, 35, 20);
contentPane.add(textField_7);
JComboBox comboBox_8 = new JComboBox();
comboBox_8.setBounds(305, 149, 97, 20);
contentPane.add(comboBox_8);
JComboBox comboBox_9 = new JComboBox();
comboBox_9.setBounds(305, 184, 97, 20);
contentPane.add(comboBox_9);
JComboBox comboBox_10 = new JComboBox();
comboBox_10.setBounds(305, 215, 97, 20);
contentPane.add(comboBox_10);
JComboBox comboBox_11 = new JComboBox();
comboBox_11.setBounds(305, 251, 97, 20);
contentPane.add(comboBox_11);
JComboBox comboBox_12 = new JComboBox();
comboBox_12.setBounds(305, 282, 97, 20);
contentPane.add(comboBox_12);
textField_8 = new JTextField();
textField_8.setColumns(10);
textField_8.setBounds(405, 149, 35, 20);
contentPane.add(textField_8);
textField_9 = new JTextField();
textField_9.setColumns(10);
textField_9.setBounds(405, 184, 35, 20);
contentPane.add(textField_9);
textField_10 = new JTextField();
textField_10.setColumns(10);
textField_10.setBounds(405, 215, 35, 20);
contentPane.add(textField_10);
textField_11 = new JTextField();
textField_11.setColumns(10);
textField_11.setBounds(405, 251, 35, 20);
contentPane.add(textField_11);
textField_12 = new JTextField();
textField_12.setColumns(10);
textField_12.setBounds(405, 282, 35, 20);
contentPane.add(textField_12);
JComboBox comboBox_13 = new JComboBox();
comboBox_13.setBounds(461, 149, 97, 20);
contentPane.add(comboBox_13);
JComboBox comboBox_14 = new JComboBox();
comboBox_14.setBounds(461, 184, 97, 20);
contentPane.add(comboBox_14);
JComboBox comboBox_15 = new JComboBox();
comboBox_15.setBounds(461, 215, 97, 20);
contentPane.add(comboBox_15);
JComboBox comboBox_16 = new JComboBox();
comboBox_16.setBounds(461, 251, 97, 20);
contentPane.add(comboBox_16);
JComboBox comboBox_17 = new JComboBox();
comboBox_17.setBounds(461, 282, 97, 20);
contentPane.add(comboBox_17);
textField_13 = new JTextField();
textField_13.setColumns(10);
textField_13.setBounds(560, 149, 35, 20);
contentPane.add(textField_13);
textField_14 = new JTextField();
textField_14.setColumns(10);
textField_14.setBounds(560, 184, 35, 20);
contentPane.add(textField_14);
textField_15 = new JTextField();
textField_15.setColumns(10);
textField_15.setBounds(560, 215, 35, 20);
contentPane.add(textField_15);
textField_16 = new JTextField();
textField_16.setColumns(10);
textField_16.setBounds(560, 251, 35, 20);
contentPane.add(textField_16);
textField_17 = new JTextField();
textField_17.setColumns(10);
textField_17.setBounds(560, 282, 35, 20);
contentPane.add(textField_17);
JButton btnNewButton = new JButton("Sell");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
btnNewButton.setBounds(10, 78, 128, 24);
contentPane.add(btnNewButton);
list.setVisible(true);
JButton btnSpeichern = new JButton("Zurück");
btnSpeichern.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
menu.main(null);
}
});
btnSpeichern.setBounds(10, 52, 128, 23);
contentPane.add(btnSpeichern);
}
}