forked from ranjansharma255/Java_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextFieldDemoLab.java
More file actions
35 lines (33 loc) · 806 Bytes
/
TextFieldDemoLab.java
File metadata and controls
35 lines (33 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code = TextFieldDemoLab width = 300 height = 300 > </applet>*/
public class TextFieldDemoLab extends Applet implements ActionListener
{
Label l1,l2;
TextField t1,t2;
public void init()
{
l1 = new Label("Enter Username");
l2 = new Label("Enter Password");
t1 = new TextField(10);
t2 = new TextField(10);
t2.setEchoChar('*');
add(l1);
add(t1);
t1.addActionListener(this);
add(l2);
add(t2);
t2.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
repaint();
}
public void paint(Graphics g)
{
g.drawString("Username : "+t1.getText(),10,200);
g.drawString("Password : "+t2.getText(),10,240);
showStatus("Press Enter After Typing");
}
}