你在程序力加上
//<applet code=你的文件.class width=300 height=200></applet>
当注释
然后编译
javac 文件.java
然后:
appletviewer 文件.java
看看能不能显示?
//<applet code=你的文件.class width=300 height=200></applet>
当注释
然后编译
javac 文件.java
然后:
appletviewer 文件.java
看看能不能显示?
解决方案 »
- 正则表达式的(?is)
- 在远程调用时候gc回收对象的问题啊。。。。。。。。。。。。。。。。。。。。。
- 同一个dll,用java代码能调到,用jnative第三方jar包调不到.
- 打包好的jar文件没法执行
- 跪求答案 try语句中部分语句不能实现
- jawin 调用VB dll
- 访问oracle数据库表的非常奇怪的问题,郁闷了我半天,请朋友们帮忙!
- 如何创建这样一个对象?
- 为什么捕获不到功能键?
- ArrayList实现了List接口,为什么没有重写其iterator();抽象方法???为什么
- 如何使用QueryDataSet插入与更新一条记录?
- 关于java编码的讨论,请高手发言(需要对系统有所了解)!
英文程序是这样的
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);
}
}
这两个程序我在编的机器上一样的操作,运行没有问题
谢谢了,用得的方法可以显示,但是为什么在ie里面不行呢???如果问题解决了一定高分相送
其实最简单的是设置
java Application 中所有的控件的字体为宋体,字体大小为12
祝你好运!----------------------
我相信我会成功!
你下载了插件吗?(jre1.4)
我不是高手。
/*用于内码转换的两个方法*/
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;
}
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;
}