java——applet程序变成jfarme程序

来源:百度知道 编辑:UC知道 时间:2024/09/22 09:49:23
请高人把这段applet——java小程序变成jframe的就是一个按钮一点然后就会运行下面的算法,生成图形。
import java.awt.*;
import javax.swing.*;
import java.lang.*;
import java.awt.event.*;
public class ActiveJulia extends JApplet implements Runnable{
private Thread t;
float b=0; //cx的值
float c=0; //cy的值
private boolean isForward = true;
private String infoX, infoY, XY;
Image offscreenimage=null; //缓冲区中的图形
Graphics offscreenbuffer=null; //缓存中的g
int width=600;
int height=600;
public void init()
{
t = new Thread(this);
t.start();
//创建缓冲区内的图形
offscreenimage=this.createImage(width,height);
//得到g
offscreenbuffer=offscreenimage.getGraphics();
}
public void update(Graphics g)
{
paint(g);
}
public void run()
{
while(true)
{
repaint();
try
{
t.sleep(0);
}
catch(InterruptedException e) {}
}
}
public void paint(Graphics g)

网页中内嵌的话还是放iframe比较好。
<Iframe src="xx.htm" width="600" height="600" scrolling="no" frameborder="0"></iframe>

xx.htm:
添加按钮。或者是直接<a href="xxxx.htm">开始</a>

xxxx.htm:
添加applet
<applet codebase=".."
archive=".."
code=".."
name=".."
mayscript
width ="600"
height ="600"
hspace ="0"
align ="top">
<param name=".." value="..">
.......
</applet>