【Java开源代码栏目提醒】:网学会员,鉴于大家对Java开源代码十分关注,论文会员在此为大家搜集整理了“ko12_3.java”一文,供大家参考学习!
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class ko12_3 extends Applet implements ActionListener
{
int x,y,z;
double a,b;
Button bn1=new Button("Sin猧");
Button bn2=new Button("Cos猧");
Button bn3=new Button("睲埃");
public void init()
{
add(bn1);
add(bn2);
add(bn3);
bn1.addActionListener(this);
bn2.addActionListener(this);
bn3.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
Graphics g=getGraphics();
if (e.getSource()==bn1)
{
for (x=0;x<=360;x+=9)
{
a=Math.sin(x*Math.PI/180);
y=(int)(80+40*a);
g.drawString("*",x,y);
}
}
if (e.getSource()==bn2)
{
for (x=0;x<=360;x+=9)
{
b=Math.cos(x*Math.PI/180);
z=(int)(80+40*b);
g.drawString("*",x,z);
}
}
if (e.getSource()==bn3)
repaint();
}
}
上一篇:
ko12_2.java
下一篇:
浅析普外科围手术期抗菌药物的应用