new Font(s, Font.BOLD, 16)请问s是字体名吗?

解决方案 »

  1.   

    因为你的setFont(new Font(s, Font.BOLD, 16));
    这段话没有放在初始化init() 里面
    如果是这样就没问题了
    import java.awt.*;
    import java.applet.Applet;
    public class Hello_applet extends Applet {
        String s;
        public void init() {
            s="Hello! welcome into Applet world";
             setFont(new Font(s, Font.BOLD, 16));
        }
        public void paint(Graphics g)
        {
                  
            g.drawString(s, getSize().width/4, getSize().height/2);
        }
    }