import java.applet.Applet;
import java.awt.*;
import java.lang.*;public class MyApplet4 extends Applet
{  
  private TextField hostField;
    public void init()
      {   
          Panel hostPanel = new Panel();
          hostPanel.setLayout(new GridLayout(2, 1));
          hostPanel.add(new Label("Host"));
          hostField = new TextField("YourCompany.com"); 
                  // 由 读 者 填 其 邮 件 服 务 器IP
          hostPanel.add(hostField);
          Container contentPane = getContentPane();
 contentPane.add(hostPanel );
          
        }
  public void paint(Graphics g)
{
  g.drawString("test",30,30); 
}
}

解决方案 »

  1.   

    public void init()
          {   Panel hostPanel = new Panel();
              hostPanel.setLayout(new GridLayout(2, 1));
              hostPanel.add(new Label("Host"));
              hostField = new TextField("YourCompany.com"); 
                      // 由 读 者 填 其 邮 件 服 务 器IP
              hostPanel.add(hostField);
              add(hostPanel);
              ~~~~~~~~~~~~~~~~加这一句
            }
      

  2.   

    感谢rinehart和hexiaofeng!!!
    问题解决了!
    hexiaofeng的答案我试过了,提示getContentPane方法出错!
    rinehart答案很好地解决了问题!
    给分~~~~
      

  3.   

    不好意思!! 搞错了!
    应该是hexiaofeng的答案解决了问题!!