跪求一段APPLET程序 要点击按钮能够画正玄曲线 (作图也行)要使用EVENT哦 谢谢 同题APPLET程序 要点击按钮能够画正玄曲线 (作图也行)要使用EVENT 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.*;import java.awt.event.*;import java.applet.Applet;public class animation1 extends Applet implements Runnable,ActionListener{ Thread hThread; int xx=0,yy=0; int x=0; Label label1; public void init() { this.setBackground(Color.lightGray); Button myButton1=new Button("开始"); myButton1.addActionListener(this); this.add(myButton1); Button myButton2=new Button("暂停"); myButton2.addActionListener(this); this.add(myButton2); Button myButton3=new Button("停止"); myButton3.addActionListener(this); this.add(myButton3); } public void start() { //创建线程 if(hThread==null) hThread=new Thread(this); //启动线程 } public void actionPerformed(ActionEvent e) { if(e.getActionCommand()=="开始") { hThread.start(); } if(e.getActionCommand()=="暂停") { hThread.suspend(); } if(e.getActionCommand()=="停止") { hThread.resume(); } } public void run() { //线程run方法 while(true) { repaint(); try { //线程睡眠时间 hThread.sleep(20); } catch(InterruptedException e) {} } } public void paint(Graphics g) { for(int x1=0;x1<=x;x1++) { double y1=200.0+100.0*Math.sin((double)x1*Math.PI/180.0); int x11=x1+1; double y11=200.0+100.0*Math.sin((double)x11*Math.PI/180.0); g.drawLine(x1,(int)y1,x11,(int)y11); } x++; if(x>360)x=0; double y=200.0+100.0*Math.sin((double)x*Math.PI/180.0); g.drawLine(xx,yy,x,(int)y); xx=x; yy=(int)y; } public void stop() { hThread= null; } } java 鼠标右击菜单JPopupMenu中 JMenuItem 子菜单怎么实现 一道JAVA编程题? 急问ResultSet问题 产生螺旋数字 log4j Java如何在函数中修改传入参数的值 写了CET4分数换算程序,有个错误,请DX执教.. 什么情况下,对象会超出它的作用域,能否举一个代码实例?谢谢 如何使没有装JAVA PLUGIN的浏览器在运行APPLET时自动提示安装信息 数据类型的转换 关于执行效率的问题,请进来看一看 谁能回答这个问题啊
import java.awt.event.*;
import java.applet.Applet;public class animation1 extends Applet implements Runnable,ActionListener
{
Thread hThread;
int xx=0,yy=0;
int x=0;
Label label1;
public void init()
{
this.setBackground(Color.lightGray);
Button myButton1=new Button("开始");
myButton1.addActionListener(this);
this.add(myButton1);
Button myButton2=new Button("暂停");
myButton2.addActionListener(this);
this.add(myButton2);
Button myButton3=new Button("停止");
myButton3.addActionListener(this);
this.add(myButton3);
}
public void start()
{
//创建线程
if(hThread==null)
hThread=new Thread(this);
//启动线程
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()=="开始")
{
hThread.start();
}
if(e.getActionCommand()=="暂停")
{
hThread.suspend();
}
if(e.getActionCommand()=="停止")
{
hThread.resume();
}
}
public void run()
{
//线程run方法
while(true)
{
repaint();
try
{
//线程睡眠时间
hThread.sleep(20);
}
catch(InterruptedException e)
{}
}
}
public void paint(Graphics g)
{
for(int x1=0;x1<=x;x1++)
{
double y1=200.0+100.0*Math.sin((double)x1*Math.PI/180.0);
int x11=x1+1;
double y11=200.0+100.0*Math.sin((double)x11*Math.PI/180.0);
g.drawLine(x1,(int)y1,x11,(int)y11);
}
x++;
if(x>360)x=0;
double y=200.0+100.0*Math.sin((double)x*Math.PI/180.0);
g.drawLine(xx,yy,x,(int)y);
xx=x;
yy=(int)y;
}
public void stop()
{
hThread= null;
}
}