• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

my 1st applet....problem!

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my applet is always saying access denied....what is wrong....
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Password extends Applet implements ActionListener
{
Label password = new Label("Enter your password");
TextField answer = new TextField("", 10);
public void init()
{
add(password);
add(answer);
answer.addActionListener(this);
answer.requestFocus();
}
public void actionPerformed(ActionEvent e)
{
String reply = answer.getText();
Label theOK = new Label("");
if(reply == "Rosebud")
{
theOK.setText("Access Granted");
add(theOK);
remove(answer);
invalidate();
validate();
}
else if(reply != "Rosebud")
{
theOK.setText("Access Denied");
add(theOK);
remove(answer);
invalidate();
validate();
}
}
}
 
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
deb,
The problem was the method used to compare the correct password to what the user entered. Make the changes shown below and it should work fine.

Hope this helps.
If not, let us know.
Stephanie
 
reply
    Bookmark Topic Watch Topic
  • New Topic