欢迎来到天天文库
浏览记录
ID:49611319
大小:630.00 KB
页数:26页
时间:2020-03-02
《java实验报告实验六java图形用户界面.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.信息工程学院实验报告的内容与格式按任课教师的要求书写。Java程序设计实习报告JAVA图形用户界面实验六Java图形用户界面1.实验目的(1)掌握图形用户界面基本组件。(2)了解如何使用布局管理器对组件进行管理。(3)掌握Java事件处理机制。2.实验内容实验题1编写一个模拟计算器的程序,使用面板和网格布局,添加一个文本框,10个数字按钮(0-9),4个加减乘除按钮,一个等号按钮,一个清除按钮,要求将计算公式和结果显示在文本框中。运行结果:word范文.加法:主要代码:privatevoidinitComponents(){jButton1=newjavax.swi
2、ng.JButton();jButton2=newjavax.swing.JButton();word范文.jButton3=newjavax.swing.JButton();jButton4=newjavax.swing.JButton();jButton5=newjavax.swing.JButton();jButton6=newjavax.swing.JButton();jButton7=newjavax.swing.JButton();jButton8=newjavax.swing.JButton();jButton9=newjavax.swing.JButt
3、on();jButton10=newjavax.swing.JButton();jButton11=newjavax.swing.JButton();jButton12=newjavax.swing.JButton();jButton13=newjavax.swing.JButton();jButton14=newjavax.swing.JButton();jButton15=newjavax.swing.JButton();jTextField1=newjavax.swing.JTextField();setStub(null);jButton1.setText("
4、3");jButton1.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){jButton1ActionPerformed(evt);}});jButton2.setText("1");jButton2.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.Action
5、Eventevt){jButton2ActionPerformed(evt);}});jButton3.setText("5");jButton3.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){jButton3ActionPerformed(evt);}});word范文.jButton4.setText("2");jButton4.addActionListener(newjava.awt.ev
6、ent.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){jButton4ActionPerformed(evt);}});jButton5.setText("6");jButton5.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){jButton5ActionPerformed(evt);}});jB
7、utton6.setText("8");jButton6.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEventevt){jButton6ActionPerformed(evt);}});jButton7.setText("4");jButton7.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerfor
此文档下载收益归作者所有