30-08-2011, 12:44 PM
Code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*
<applet code="TextDemo" width=300 height=300>
</applet>
*/
public class TextDemo extends Applet implements ActionListener
{
TextField name,pass;
public void init()
{
Label namep=new Label("Name ",Label.RIGHT);
Label passp=new Label("Password ",Label.RIGHT);
name = new TextField(12);
pass = new TextField(8);
pass.setEchoChar('?');
add(namep);
add(name);
add(passp);
add(pass);
name.addActionListener(this);
pass.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
repaint();
}
public void paint(Graphics g)
{
g.drawString("Name " + name.getText(),6,60);
g.drawString("Selected Item in Name " +
name.getSelectedText(),6,80);
g.drawString("Password " + pass.getText(),6,100);
}
}