I need to change Java code set up I want to add a method. Whatis the best way of adding the method?
Existing code
private void LogsubmitActionPerformed(java.awt.event.ActionEventevt){
try {
String password = jPassword.getText();
String username = jtxtUsername.getText();
File texting = new File(“Log.txt”);
//open file in append mode
BufferedWriter writer;
writer = new BufferedWriter(new FileWriter(texting,true));
//date and time
Date currentTime =Calendar.getInstance().getTime();
boolean valid = false;
//used a hard-coded username and password
if(username.equals(“anna”)&&(password.equals(“password”)))
{
jtxtUsername.setText(null);
jPassword.setText(null);
JOptionPane.showMessageDialog(null, “success”);
writer.write(username + currentTime);
writer.write(“success”);
valid = true;
}
else if(!valid)
JOptionPane.showMessageDialog(null, “invalid password”);
writer.write(password + currentTime);
writer.write(“failed”);
writer.close();
} catch (IOException ex){
Logger.getLogger(LoginApp.class.getName()).log(Level.SEVERE, null,ex);
}
}
I would like to add public boolean testUser(String jtxtUsername,String jPassword) after the private voidLogsubmitActionPerformed(java.awt.event.ActionEvent evt) method.When I add I get an error of illegal start of expression.
Expert
OR
PayPal Gateway not configured
OR
PayPal Gateway not configured
PayPal Gateway not configured
PayPal Gateway not configured