Ich habe alle Änderungen versucht, aber es zeigt ungültige Anmeldeinformationen. Bitte, bitte, um dies zu lösen.Egal, aber Authentifizierung schlägt fehl - Java - Swing
Es lehnt einfach die Kombination ab und ich bin darüber verwirrt.
Es ist ein logischer Fehler.
Ich möchte Benutzername zu Tabelle hinzufügen, sobald es funktioniert.
Ich habe alle Pakete hinzugefügt und alle Ausnahmen entfernt, aber es funktioniert nicht.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Authenticate extends JFrame implements ActionListener
{
JLabel l1,l2,l3,l4,l5,l6,l7,l8;
JPasswordField jp1,jp2;
JComboBox c1,c2,c3;
JTextField t1,t2,t3;
JTextArea ta;
JButton jb1,jb2;
String[] day = new String[31];
String[] year = new String[40];
String[] month = new String[12];
public Authenticate()
{
Container c = getContentPane();
c.setLayout(new FlowLayout(FlowLayout.CENTER));
l1 = new JLabel("Name");
l2 = new JLabel("E-mail ID");
l3 = new JLabel("Address");
l4 = new JLabel("User name");
l5 = new JLabel("Password");
l6 = new JLabel("Confirm Password");
l7 = new JLabel("DOB");
l8 = new JLabel(" ");
jp1 = new JPasswordField(10);
jp2 = new JPasswordField(10);
jp1.setEchoChar('$');
jp2.setEchoChar('*');
t1 = new JTextField(10);
t2 = new JTextField(10);
t3 = new JTextField(10);
ta = new JTextArea(3,15);
jb1 = new JButton("Submit");
jb2 = new JButton("Reset");
for(int i=0;i<31;i++)
{
day[i] = String.valueOf(i+1);
}
for(int i=0;i<35;i++)
{
year[i] = String.valueOf(i+1980);
}
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
c1 = new JComboBox(day);
c2 = new JComboBox(month);
c3 = new JComboBox(year);
jb1.addActionListener(this);
jb2.addActionListener(this);
c.add(l1);
c.add(t1);
c.add(l2);
c.add(t2);
c.add(l3);
c.add(ta);
c.add(l4);
c.add(t3);
c.add(l5);
c.add(jp1);
c.add(l6);
c.add(jp2);
c.add(l7);
c.add(c1);
c.add(c2);
c.add(c3);
c.add(jb1);
c.add(jb2);
c.add(l8);
setSize(500,500);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent ae)
{
String s = ae.getActionCommand();
String s1,s2,s3;
s1 = t3.getText();
s2 = jp1.getText();
s3 = jp2.getText();
if(s.equals("Submit")) //submit btn
{
if(s1.equalsIgnoreCase("Ghiridhar") && s2.equals("Achiever") && s2==s3) // right credentials
l8.setText("Login Successful");
else
{
l8.setText("Invalid Credentials");
t3.setText(" ");
jp1.setText("");
jp2.setText("");
} //else
} //inner if
else // reset btn
{
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");
ta.setText(" ");
jp1.setText("");
jp2.setText("");
l8.setText(" ");
} //else
} // action fn
public static void main(String a[])
{
Authenticate a1 = new Authenticate();
}
}
Bitte unterstützen Sie auf diesen Aspekt.
Bitte Einrücken Sie Ihren Code richtig, das Lesen ist Folter. –
1) Verwenden Sie eine logische und konsistente Form der Einrückung von Codezeilen und -blöcken. Die Einrückung soll den Codefluss leichter nachvollziehen lassen! 2) Um eine bessere Hilfe zu erhalten, sollten Sie ein [MCVE] oder [Short, Self Contained, Correct Example] (http://www.sscce.org/) veröffentlichen. 3) *** "Bitte helfen Sie bei diesem Aspekt." *** Bitte stellen Sie eine Frage. –