• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applets

 
josephine chen
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

<pre>
import java.awt.*;
import java.awt.event.*;
class TextBox extends Frame implements KeyListener{
TextField t1;
void createtext(){
System.out.println("create text");
t1 = new TextField();
add(t1);
setLayout(new FlowLayout());
setVisible(true);
setSize(200,400);
t1.addKeyListener(this);
}
public void keyPressed(KeyEvent e){
if (e.getKeyCode() == 10){
System.out.println("fdaSD");
}
}
public void keyReleased(KeyEvent e){ }
public void keyTyped(KeyEvent e){ }


}
class box extends java.applet.Applet{
public void init(){
System.out.println("hai");
TextBox t = new TextBox();
t.createtext();
System.out.println("helloi");

}
}

</pre>
I am getting message saying applet started but my textbox doresnot appear why???
 
alberto sierra
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using the pack() and show() methods in a constructor for your frame or t.pack() and t.show() after new TextBox().
 
josephine chen
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting the applet but the problem is i am not able to close it.
What should I do to close it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic