好像只可以用写两个string在不同的位置的方法让他们看起来好像是在两行

解决方案 »

  1.   

    public class Myapplet extends Applet {

      public void init()
      { 
      Button pressbutton=new Button("press");
      pressbutton.setBackground(Color.yellow);
      
      TextField textme=new TextField(50);
      textme.setBackground(Color.orange);
      textme.setEditable(true);
      textme.setVisible(true);
      //textme.requestFocus();
      this.add(textme);
      
      this.add(pressbutton);
      }
      public void paint(Graphics g)
      {
        g.drawString("this is the first string. \n this is the second string.",20,90);
         g.drawString(" this is the second string.",20,110);
      }
    }
    可完成。
      

  2.   

    g.drawString("this is the first string."+" \n"+" this is the second 
    string.",20,90);  
      

  3.   

    to:hexiaofeng(java爱好者)
    我用你的方法,但还是不能达到换行的目的,请问有其他办法吗?
      

  4.   

        同意vdragon(紫龙),drawString只能这么用。不过可以用Font.Height来确定下一行的
    位置。