-1

So i'm a beginner in java and i've been encountering this problem on cmd, whenever i try to show my jframe in cmd i've been getting this note "uses or overrides deprecated API" and "recompile with -Xlint..". When i tried to erase the action listener of my enter button the jframe shows and works so i thought that it might be the code in enter.addActionListener is the problem. thank you.

    enter.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
    String userText;
    String pwdText;
    userText = uss.getText();
    pwdText = pss.getText();
    if (userText.equals("user") && pwdText.equals("pass")) {

         JOptionPane.showMessageDialog(null, "Login                         
    Successful","Message",JOptionPane.PLAIN_MESSAGE);
    } 
    else { 
        JOptionPane.showMessageDialog(null, "Invalid Username or 
    Password","Message",JOptionPane.PLAIN_MESSAGE);
          }
        }
    });
poyo
  • 23
  • 6
  • What does your IDE tell you? Does it indicate any of this code as deprecated? –  Aug 01 '19 at 10:40
  • no it doesn't :(( – poyo Aug 01 '19 at 11:07
  • *"When i tried to erase the action listener.."* Whoa there! What happened when you compiled with the `-Xlint` option? Compiler message advice is good advice that will likely save guessing. – Andrew Thompson Aug 01 '19 at 12:23

1 Answers1

0

You might be using JPasswordField and

pss.getText()

is deprecated and you have to use

String.valueOf(pss.getPassword())

If you compile with Xlint option the compiler tells you what is deprecated.

zomega
  • 1,538
  • 8
  • 26