0% found this document useful (0 votes)
11 views5 pages

Ajp 12

Uploaded by

nihaltamboli4380
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

Ajp 12

Uploaded by

nihaltamboli4380
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Practical NO:-12

Name:-Nihal Ayub Tamboli


Roll No:-2218 Batch:-T1

import javax.swing.*;
import java.awt.*;
public class PasswordDemo
{
public static void main(String[] args)
{
JFrame f=new JFrame("JPasswordField Ex.");
JPasswordField jp= new JPasswordField();
JLabel l1=new JLabel("Password:");
l1.setBounds(40,120,100,50);
l1.setFont(new Font ("Serif",
Font.BOLD,18));
jp.setBounds(120,120,120,50);
jp.setEchoChar('#');
f.add(jp);
f.add(l1);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}
Output
Practical NO:-12

import javax.swing.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="UserAuthentication.class" height=300 width=300>
</applet>*/
public class UserAuthentication extends JApplet implements ActionListener
{
JTextField t1;
JPasswordField jp1;
JButton b1;
JLabel l2;
public void init(){
jp1=new JPasswordField(20);
jp1.setBounds(20,50,200,30);
t1=new JTextField(20);
t1.setBounds(20,30,200,30);
b1=new JButton("OK");
b1.setBounds(20,80,80,30);
l2=new JLabel();
add(t1);
Practical NO:-12

add(jp1);
add(b1);
add(l2);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String s1=t1.getText();
String s2=jp1.getText();
l2.setText("Name - "+s1+" "+"Password - "+s2);
}
}

Output

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code="AddNum.class" height=300 width=300></applet>*/
public class AddNum extends Applet implements ActionListener
{
TextField t1,t2,t3;
Practical NO:-12

Label l1,l2,l3;
Button b1;
public void init()
{
l1=new Label("Enter 1st no.");
t1=new TextField();
l2=new Label("Enter 2nd no.");
t2=new TextField();b1=new Button("ADDITION");
l3=new Label("Result");
t3=new TextField();
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
add(l3);
add(t3);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
int a=Integer.parseInt(t1.getText());
int b=Integer.parseInt(t2.getText());
int c=a+b;
String s1=""+c;
t3.setText(s1);
}
}

Output
Practical NO:-12

You might also like