I am not getting this program since i beginner to applet programming

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/*<applet code=Login height=500 width=300></applet>*/

public class Login extends JApplet implements ActionListener
{
JLabel jl1,jl2,jl3,jl4,jl5;
JTextField jt;
JPasswordField jp1,jp2;
JButton jb;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
jl1=new JLabel("Username : ");
jl2=new JLabel("Password : ");
jl3=new JLabel("Confirm password : ");
jl4=new JLabel();
jl5=new JLabel();
jt=new JTextField(20);
jp1=new JPasswordField(20);
jp2=new JPasswordField(20);
jb=new JButton("Login");
jb.addActionListener(this);
c.add(jl1);
c.add(jt);
c.add(jl2);
c.add(jp1);
c.add(jl3);
c.add(jp2);
c.add(jb);
c.add(jl4);
c.add(jl5);
}
public void actionPerformed(ActionEvent ae)
{
String s=ae.getActionCommand();
String p1,p2;
if(jp1==jp2)
{
    jl4.setText("Welcome");
}
else
{
    jl4.setText("Password Mismatch");
}
}
}

everytime i check my program it shows else condition
whether password fields are same or different

is there anyone who can help me?

You should use the equals() method to compare Strings.

Your if test using == compares two variables to see it they both refer to the same object. You want to get the contents of those objects as Strings and compare them.

I totally forgot about equals() method concept in java

i got the output thnx for the help

Note: Login.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

how to solve this issue

that's not an error, it's a warning.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/*<applet code=Login height=500 width=300></applet>*/

public class Login extends JApplet implements ActionListener
{
JLabel jl1,jl2,jl3,jl4;
JTextField jt;
JPasswordField jp1,jp2;
JButton jb;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
jl1=new JLabel("Username : ");
jl2=new JLabel("Password : ");
jl3=new JLabel("Confirm : ");
jl4=new JLabel();
jt=new JTextField(15);
jp1=new JPasswordField(15);
jp2=new JPasswordField(15);
jb=new JButton("Login");
jb.addActionListener(this);
c.add(jl1);
c.add(jt);
c.add(jl2);
c.add(jp1);
c.add(jl3);
c.add(jp2);
c.add(jb);
c.add(jl4);
}
public void actionPerformed(ActionEvent ae)
{
String s=ae.getActionCommand();
String p1,p2;
p1=jp1.getText();
p2=jp2.getText();
if(p1.equals(p2))
{
    jl4.setText("Welcome, "+jt.getText());
}
else
{
    jl4.setText("Password Mismatch");
}
}
}

but is there anyway to solve this in this program

anyway to solve this in this program

Please explain what the problem is now. What does the program do that you want to change.

Note: Login.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

this program gives this warning how to solve it

The compiler is asking you to add the -Xlint option to the command line for the compiler so that it will display the full text of all the warning messages.
Your program must have some code that the compiler thinks could be a problem.
Add the the -Xlint option to get the full details. Here is the commandline I use for compiling:
F:\Java\jdk1.6.0_29\bin\javac.exe -Xlint -g -deprecation -classpath D:\JavaDevelopment\;.;... SnowMen.java

can u plz give me full details since i am new to applet programming
& never seen such kind of error or warning

commented: NormR1 has already explained what you are asking in this post. +0

F:\Java\jdk1.6.0_29\bin\javac.exe -Xlint ...

Change your compiler command line to include the -Xlint option as shown above.

its basically telling you that you are using a deprecated api.. meaning : its an older class or method and that it might cause an error like a buffer overflow... http://www.javacoffeebreak.com/faq/faq0008.html my netbeans says: getText() is "Deprecated. As of Java 2 platform v1.2, replaced by getPassword." for lines 39 & 40. http://stackoverflow.com/questions/10443308/why-gettext-in-jpasswordfield-was-deprecated

Thnx for the help NormR1 & cOrRuPtG3t!x for helping me
now question is solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.