import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class calculateApplet extends Applet implements ActionListener
{
public TextField tf1,tf2,tf3;
Button b_deng;
Choice fuHao;
Panel pp,pp1,pp2;
double a,b,c;
String cc;
AudioClip music;
Image ima;
public void init()
{try{
this.setBackground(Color.LIGHT_GRAY);
this.setLayout(new BorderLayout());
tf1=new TextField(20);
tf2=new TextField(8);
tf3=new TextField(8);
b_deng=new Button("=");
b_deng.addActionListener(this);
fuHao=new Choice();
fuHao.addItem("+");
fuHao.addItem("-");
fuHao.addItem("*");
fuHao.addItem("/");
pp=new Panel(null);
pp1=new Panel(new FlowLayout());
pp2=new Panel(new FlowLayout());
pp1.setBackground(Color.yellow);
pp2.setBackground(Color.yellow);
pp1.add(new Label("计算结果:"));
pp1.add(tf1);
pp2.add(tf2);
pp2.add(fuHao);
pp2.add(tf3);
pp2.add(b_deng);
pp.add(pp1);
pp.add(pp2);
// pp.setBackground(Color.red);
pp1.setBounds(10,10,300,40);
pp2.setBounds(10,60,300,40);
this.add(pp);
music=getAudioClip(getDocumentBase(),"voice/挥着翅膀的女孩-容祖儿.wav");
music.loop();
ima=getImage(getDocumentBase(),"00.jpg");
repaint();
this.setVisible(true);}catch(Exception eee){System.out.print(eee);}
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
g.drawImage(ima,0,0,this);
}
public void actionPerformed(ActionEvent e)
{
try
{
a=Double.parseDouble(tf2.getText());
b=Double.parseDouble(tf3.getText());
if(fuHao.getSelectedItem().equals("+"))
{
c=a+b;
cc=new String(Double.toString(c));
tf1.setText(cc);
}
if(fuHao.getSelectedItem().equals("-"))
{
c=a-b;
cc=new String(Double.toString(c));
tf1.setText(cc);
}
if(fuHao.getSelectedItem().equals("*"))
{
c=a*b;
cc=new String(Double.toString(c));
tf1.setText(cc);
}
if(fuHao.getSelectedItem().equals("/"))
{
c=a/b;
cc=new String(Double.toString(c));
tf1.setText(cc);
}
}
catch(Exception ee){}
}
}
jisuanqi.rar_java applet jisuanqi
版权申诉
68 浏览量
2022-09-24
15:36:40
上传
评论
收藏 3KB RAR 举报
APei
- 粉丝: 62
- 资源: 1万+
最新资源
- Python闭包:深入理解与应用场景解析.zip
- Win64OpenSSL-3-3-0.exe
- 课高分程设计-基于C++实现的民航飞行与地图简易管理系统-南京航空航天大学
- 航天器遥测数据故障检测系统python源码+文档说明+数据库(课程设计)
- 北京航空航天大学操作系统课设+ppt+实验报告
- 基于Vue+Echarts实现风力发电机中传感器的数据展示监控可视化系统+源代码+文档说明(高分课程设计)
- 基于单片机的风力发电机转速控制源码
- 基于C++实现的风力发电气动平衡监测系统+源代码+测量数据(高分课程设计)
- 毕业设计- 基于STM32F103C8T6 单片机,物联网技术的太阳能发电装置+源代码+文档说明+架构图+界面截图
- 基于 LSTM(长短期记忆)(即改进的循环神经网络)预测风力发电厂中风力涡轮机产生的功率+源代码+文档说明
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈