ie无法正常运行加载java applet
在myeclipse中测试一个使用javaapplet的例子,得不到应有的结果。项目中主要的文件是yy.java和index.jspyy.java文件内容如下:packa...
在myeclipse中测试一个使用java applet的例子,得不到应有的结果。 项目中主要的文件是yy.java和index.jsp yy.java文件内容如下: package com.applet;import javax.swing.*;import java.awt.*;public class yy extends JApplet{ private long s_red; private long s_orange; private long s_green; private int count=1; private int radius=50; private int step=55; private int y=30; private int x=50; public void init(){ try{ s_red=Integer.parseInt(getParameter("red")); s_orange=Integer.parseInt(getParameter("orange")); s_green=Integer.parseInt(getParameter("green")); count=Integer.parseInt(getParameter("count")); }catch(Exception e){ s_red=1000; s_orange=1000; s_green=1000; count=1; } } public void paint(Graphics g){ String text[]={"��","��","��"}; g.setFont(new Font("����",1,12)); g.drawString("���ͣ��ʱ�䣺"+s_red/1000,50,100); g.drawString("�Ƶ�ͣ��ʱ�䣺"+s_orange/1000,50,120); g.drawString("�̵�ͣ��ʱ�䣺"+s_green/1000,50,140); g.drawString("ѭ������"+count,50,160); g.setColor(Color.lightGray); for(int i=0;i<3;i++){ g.drawString(text[i], x+i*step+20, 20); g.fillOval(x+i*step, y, radius, radius); } run(g); } private void run(Graphics g){ Graphics clear=g; Color color[]={Color.red,Color.orange,Color.green}; long s_wait[]={s_red,s_orange,s_green}; int i=0; try{ synchronized(this){ for(i=0;i<count;i++){ for(int j=0;j<3;j++){ g.setColor(color[j]); g.fillOval(x+j*step, y, radius, radius); this.wait(s_wait[j]); clear.setColor(Color.lightGray); clear.fillOval(x+j*step, y, radius, radius); } } } g.drawString("No electricity!!",50,180); }catch(Exception e){ e.printStackTrace(); } }}index.jsp文件如下:<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK%><html><head><meta http-equiv="Content-Type" content="text/html; charset=GBK"><title><jsp:param >子标签的使用</title></head><body><jsp:plugin type="applet" code="com.applet.yy.class" codebase="./applet" width="550" height="390"> <jsp:params> <jsp:param name="red" value="2000" /> <jsp:param name="orange" value="1000" /> <jsp:param name="green" value="3000" /> <jsp:param name="count" value="2" /> </jsp:params> <jsp:fallback>加载Java Applet失败!</jsp:fallback></jsp:plugin></body></html>yy文件直接运行结果如图IE浏览器中运行结果如图查看IE源文件
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询