• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compiletimerror

 
TAHA ALI
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
when i compile this code which is given below.
it shows an error.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class TextFieldDemo1 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 text in name" + name.getSelectedText(),6, 80);
g.drawString("Password " + pass.getText(),6, 100);

}
}
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ali,
I don't know what I did wrong, but when I compiled your class on my Windows XP machine with J2SE SDK 1.4.2, I didn't get an error. I also managed to execute the applet using the "appletviewer". I hope that's all right?
Perhaps you could give me a clue about what sort of error I am meant to get (so I can try again).
Good Luck,
Avi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic