你在程序力加上
//<applet code=你的文件.class width=300 height=200></applet>
当注释
然后编译
javac 文件.java
然后:
appletviewer 文件.java
看看能不能显示?

解决方案 »

  1.   

    我前两天刚用过啊,我没调过什么东西啊!!!我还不知道要调什么地方呢有什么地方可以调的,请说出来我试试
    英文程序是这样的
    import java.applet.*;
    import java.awt.*;
    class Student
    {
    float math,english,sum;
    float f(float k1,float k2)
    {
    sum=k1*math+k2*english;
    return sum;
    }
    }public class Average extends Applet
    {
    Student wanghong,lihong;
    public void init()
    {
    wanghong=new Student();
    lihong=new Student();
    wanghong.math=60.0f;
    wanghong.english=80f;
    lihong.math=70.0f;
    lihong.english=90.0f;
    wanghong.sum=wanghong.f(2.0f,2.0f);
    lihong.sum=lihong.f(2.0f,2.0f);
    }
    public void paint(Graphics g)
    {
    g.drawString("lihong sum= "+lihong.sum,12,45);
    g.drawString("wanghong sum=" +wanghong.sum,12,60);
    }
    }
    中文是这样的
    import java.applet.*;
    import java.awt.*;
    class Father
    {
    private int money;
    float weight,height;
    String head;
    String speak(String s)
    {
    return s;
    }
    }
    class Son extends Father
    {
    String hand,foot;
    }
    public class Example4_6 extends Applet
    {
    Son boy;
    public void init()
    {
    boy=new Son();
    boy.weight=1.80f;
    boy.height=120f;
    boy.head="一个头";
    boy.hand="两只手";
    boy.foot="两只脚";
    }
    public void paint(Graphics g)
    {
    g.drawString(boy.speak("我是儿子"),5,20);
    g.drawString(boy.hand+boy.foot+boy.head+boy.weight+boy.height,5,40);
    }
    }
    这两个程序我在编的机器上一样的操作,运行没有问题
      

  2.   

    yashiro(七枷社)
    谢谢了,用得的方法可以显示,但是为什么在ie里面不行呢???如果问题解决了一定高分相送
      

  3.   

    可能是找不到你的 applet.class ,是在一个目录里吗?
      

  4.   

    是在一个目录下阿,我在公司里面就是这样做的,在家就不行了,你的qq号是多少阿,csdn有的时候登陆不上来分还是会给的
      

  5.   

    问题还没有解决阿!!!!!!我用的是jdk1.4.0.1版的,操作系统是xp,而且就是这样的配置前几天还能用呢?
      

  6.   

    你的javac 时用javac -encoding GB2312 YourFile.javamouse右健,然后看你的IE的编码是否为GB2312
      

  7.   

    强制一下这web页的字符集成英文的试试....
      

  8.   

    大家说的好泪!
    其实最简单的是设置
    java Application 中所有的控件的字体为宋体,字体大小为12
    祝你好运!----------------------
    我相信我会成功!
      

  9.   

    XP 不支持java(IE)。
    你下载了插件吗?(jre1.4)
      

  10.   

    不是这个原因吧,我的2000系统上也不能显示 出applet来,难道说2000也不支持java(IE)?
      

  11.   

    你这样骂人,谁还会帮你解决。可能是内码转换的问题,下面给你两个方法参考一下,也许能解决你的问题,因为你的问题并不是每个人的机器上都能出现的,所以没法帮你试,碰到问题要尽量自己解决,这样效果会更好。
    我不是高手。
    /*用于内码转换的两个方法*/
      public static String GBToUnicode(String strIn)
      {
         String strOut = null;
         if(strIn == null||(strIn.trim().equals("")))
         {
           return strIn;
          }
           try{
               byte[] b = strIn.getBytes("ISO8859_1");
               strOut = new String(b,"GBK");
               }catch(Exception ee){ }
            return strOut;
      }  public static String UnicodeToGB(String strIn)
      {
         byte[] b;
         String strOut = null;
         if(strIn == null||(strIn.trim().equals("")))
         {
           return strIn;
          }
           try{
               b = strIn.getBytes("GBK");
               strOut = new String(b,"ISO8859_1");
               }catch(Exception ee){ }
            return strOut;
      }
      

  12.   

    实在不行,只好求助于国际化了。也就是说正规的程序里面是不允许出现汉字的(注释除外)。也就是把所有汉字都放到一个property文件里,给你一个例子:
    import java.io.Serializable;
    import java.util.*;// Referenced classes of package com.optel.telemaster.util:
    //            LIException, Statuspublic class EnumType
        implements Serializable
    {    public EnumType()
        {
            code = 0;
        }    public EnumType(int value)
        {
            code = value;
        }    public int getIntValue()
        {
            return code;
        }    public Status setIntCode(int value)
            throws LIException
        {
            if(!isValidCode(value))
            {
                throw new LIException(new Status(10002));
            } else
            {
                code = value;
                return new Status(1);
            }
        }    public String getStringValue()
            throws LIException
        {
            String ret;
            try
            {
                ResourceBundle messages = getDefaultResourceBundle();
                String str = Integer.toString(code);
                ret = messages.getString(str);
            }
            catch(MissingResourceException ex)
            {
                throw new LIException(new Status(10003), ex);
            }
            return ret;
        }    public Status setStringValue(String str)
            throws LIException
        {
            int index = getIndex(str);
            if(index == 0x80000000)
            {
                throw new LIException(new Status(10002));
            } else
            {
                code = index;
                return new Status(1);
            }
        }    protected int[] getValidCode()
        {
            int temp[] = {
                1, 2, 3, 4
            };
            return temp;
        }    public boolean isValidCode(int value)
        {
            int validCodeArray[] = getValidCode();
            for(int i = 0; i < validCodeArray.length; i++)
                if(value == validCodeArray[i])
                    return true;        return false;
        }    public boolean isValidString(String str)
            throws LIException
        {
            int index = 0;
            return getIndex(str) != 0x80000000;
        }    public String getStringValue(Locale locale)
            throws LIException
        {
            String ret;
            try
            {
                ResourceBundle messages = getResourceBundle(locale);
                String str = getStringValue();
                ret = messages.getString(str);
            }
            catch(MissingResourceException e)
            {
                throw new LIException(new Status(10005), e);
            }
            return ret;
        }    public String getStringValue(int value)
            throws LIException
        {
            String ret;
            try
            {
                ResourceBundle messages = getDefaultResourceBundle();
                ret = messages.getString(Integer.toString(value));
            }
            catch(MissingResourceException ex)
            {
                throw new LIException(new Status(10003), ex);
            }
            return ret;
        }    public String getStringValue(int value, Locale locale)
            throws LIException
        {
            String str = getStringValue(value);
            String ret = getStringValue(str, locale);
            return ret;
        }    public String getStringValue(String str, Locale locale)
            throws LIException
        {
            String ret;
            try
            {
                ResourceBundle messages = getResourceBundle(locale);
                ret = messages.getString(str);
            }
            catch(MissingResourceException ex)
            {
                throw new LIException(new Status(10005), ex);
            }
            return ret;
        }    private ResourceBundle getDefaultResourceBundle()
            throws LIException
        {
            return getResourceBundle(new Locale("zh", "CN"));
        }    private ResourceBundle getResourceBundle(Locale locale)
            throws LIException
        {
            String className = getClassName();
            ResourceBundle messages;
            try
            {
                messages = ResourceBundle.getBundle(className, locale);
            }
            catch(MissingResourceException e)
            {
                throw new LIException(new Status(10004), e);
            }
            return messages;
        }    private int getIndex(String str)
            throws LIException
        {
            int index = 0x80000000;
            try
            {
                ResourceBundle messages = getDefaultResourceBundle();
                for(Enumeration enum = messages.getKeys(); enum.hasMoreElements();)
                {
                    String key = (String)enum.nextElement();
                    String value = messages.getString(key);
                    if(str.compareToIgnoreCase(value) == 0)
                    {
                        index = Integer.parseInt(key);
                        return index;
                    }
                }        }
            catch(MissingResourceException e)
            {
                throw new LIException(new Status(10003), e);
            }
            return index;
        }    private String getClassName()
        {
            String className = getClass().getName();
            int pos = className.lastIndexOf(".");
            String name = className.substring(pos + 1);
            return name;
        }    private int code;
    }
      

  13.   

    english显示正常吧,一般来说出现这样的情况,都是中文编码的问题,有没有试过楼上几位的方法?解决了吗??