日期:2014-05-20  浏览次数:20852 次

为什么我的applet运行时总是不能显示楷体.
//以下为Applet1.java
import   java.awt.*;
import   java.applet.*;
public   class   Applet1   extends   Applet
{String   strFont;
  public   void   init(){
strFont   =   getParameter( "font ");
System.out.println( "hello   init ");}

public   void   start(){
System.out.println( "hello   start ");}

public   void   stop(){
System.out.println( "hello   stop ");}

public   void   destroy(){
System.out.println( "hello   destroy ");}
public   void   paint(Graphics   g){
Font   f=new   Font( "strFont ",Font.BOLD,30);
g.setFont(f);
g.setColor(Color.blue);
g.drawString( "你好 ",0,30);}}

//以下为Applet.html
<applet   code=Applet1.class   width=400   height=200>
<param   name= "font "   value= "楷体_GB2312 ">
</applet>


------解决方案--------------------
是不是:
GB_2312
------解决方案--------------------
Font f=new Font( "strFont ",Font.BOLD,30);
g.setFont(f);
g.setColor(Color.blue);
里面好象有问题。如果要楷体的话,似乎有个字体类,可以自己搞。
还有,兄弟。我交你个小技巧
// <applet code=Applet1.class width=400 height=200>
// <param name= "font " value= "楷体_GB2312 ">
// </applet>
直接写成上面的形式,放在一起就可以了。这样用appletviewer看,很方便的。