ImageVerifierCode 换一换
格式:DOCX , 页数:9 ,大小:16.56KB ,
资源ID:12866964      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/12866964.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(java图形实验报告.docx)为本站会员(b****2)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

java图形实验报告.docx

1、java图形实验报告java图形实验报告篇一:java实验报告实验六Java图形用户界面信 息 工 程 学 院Java程序设计 实习报告JAVA图形用户界面实验六Java图形用户界面1实验目的(1)把握图形用户界面大体组件。(2)了解如何利用布局治理器对组件进行治理。(3)把握Java事件处置机制。2实验内容实验题1 编写一个模拟计算器的程序,利用面板和网格布局,添加一个文本框,10个数字按钮(0-9),4个加减乘除按钮,一个等号按钮,一个清除按钮,要求将计算公式和结果显示在文本框中。运行结果:实验报告的内容与格式按任课教师的要求书写。加法:要紧代码:private void initComp

2、onents() setStub(null); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jButton5 = new javax.swing.JButton(); jButton6 = new javax.swing.JButton(); jButton7 = new javax.swing.JButton(); jButton8 =

3、 new javax.swing.JButton(); jButton9 = new javax.swing.JButton(); jButton10 = new javax.swing.JButton(); jButton11 = new javax.swing.JButton(); jButton12 = new javax.swing.JButton(); jButton13 = new javax.swing.JButton(); jButton14 = new javax.swing.JButton(); jButton15 = new javax.swing.JButton();

4、jTextField1 = new javax.swing.JTextField(); jButton1.setText(3); jButton1.addActionListener(new java.awt.event.ActionListener() public voidactionPerformed(java.awt.event.ActionEvent evt) jButton2.setText(1); jButton2.addActionListener(new); jButton1ActionPerformed(evt); java.awt.event.ActionListener

5、() public voidactionPerformed(java.awt.event.ActionEvent evt) jButton3.setText(5); jButton3.addActionListener(new); jButton2ActionPerformed(evt); java.awt.event.ActionListener() public voidactionPerformed(java.awt.event.ActionEvent evt) jButton4.setText(2); jButton4.addActionListener(new); jButton3A

6、ctionPerformed(evt); java.awt.event.ActionListener() public voidactionPerformed(java.awt.event.ActionEvent evt) jButton5.setText(6);); jButton4ActionPerformed(evt); jButton5.addActionListener(new java.awt.event.ActionListener() public voidactionPerformed(java.awt.event.ActionEvent evt) jButton6.setT

7、ext(8); jButton6.addActionListener(new); jButton5ActionPerformed(evt); java.awt.event.ActionListener() public voidactionPerformed(java.awt.event.ActionEvent evt) jButton7.setText(4); jButton7.addActionListener(new); jButton6ActionPerformed(evt); java.awt.event.ActionListener() public voidactionPerfo

8、rmed(java.awt.event.ActionEvent evt) jButton8.setText(7); jButton8.addActionListener(new); jButton7ActionPerformed(evt); java.awt.event.ActionListener() public voidactionPerformed(java.awt.event.ActionEvent evt) jButton9.setText(0); jButton9.addActionListener(new); jButton8ActionPerformed(evt); java

9、.awt.event.ActionListener() public voidactionPerformed(java.awt.event.ActionEvent evt) jButton10.setText(9); jButton10.addActionListener(new); jButton9ActionPerformed(evt); java.awt.event.ActionListener() public voidactionPerformed(java.awt.event.ActionEvent evt) jButton11.setText(u00f7); jButton11.

10、addActionListener(new); jButton10ActionPerformed(evt); java.awt.event.ActionListener() public voidactionPerformed(java.awt.event.ActionEvent evt) jButton12.setText(u00d7); jButton12.addActionListener(new); jButton11ActionPerformed(evt); java.awt.event.ActionListener() public voidactionPerformed(java

11、.awt.event.ActionEvent evt) jButton13.setText(-); jButton13.addActionListener(new); jButton12ActionPerformed(evt); java.awt.event.ActionListener() public voidactionPerformed(java.awt.event.ActionEvent evt) 篇二:JAVA实验报告附件2:实验报告封皮 20 学年第学期 课程 实 验 报 告 学 院: 运算机科学技术 专 业: 软件工程班 级:姓 名:学 号: 任课教师: 王薇实验日期:XX年

12、11 月 02 日-1-2- 实验日期:XX年 11 月 06 日 -3-4-篇三:java图形用户界面实验报告 南京工程学院 实 验 报 告 课程名称 JAVA基础 实验项目名称 图形用户界面设计 实验学生班级 实验学生姓名学 号同组学生姓名 无实验时刻 XX年11月实验地址 实验成绩评定 指导教师签字年 月 日一、实验目的和要求1.目的:把握java AWT及Swing组件的利用方式,包括窗口、框架、对话框、布局方式、面板、文本编辑器、按钮、组合框等,合理利用委托事件处置模型,把握不同组件,不同事件的事件处置方式,设计出能够响应事件的java图形用户界面。2.要求:设计图形用户界面,事件处

13、置,异样处置并弹出对话框,提示从头输入信息。二、实验题目验证哥德巴赫猜想,添加图形用户界面三、实验方式与步骤(需求分析、算法设计思路、流程图等)import java.awt.*;import java.awt.event.*;import javax.swing.*;public class GDBH extends Frame implements ActionListener /窗口框架响应单击事件,利用awt组件设计框架private Button button; /按钮private TextField text1; /文本行private TextArea text2;/文本区pu

14、blic GDBH()super(验证哥德巴赫猜想); /设置框架窗口题目this.setBounds(450, 200, 350, 400); /设置框架的位置和尺寸 this.setResizable(false); / 设置框架大小不可改变 this.setBackground(Color.lightGray); / 设置窗口背景颜色this.setLayout(new FlowLayout(); / 默许窗口流布局 中对齐 this.add(new Label(输入一个整数);text1=new TextField(,20);this.add(text1);button=new But

15、ton(验证哥德巴赫猜想);this.add(button);button.addActionListener(this); /为按钮注册单击事件监听器,委托当前对象处置事件this.setLayout(new FlowLayout(); /默许中对齐text2=new TextArea(20,25);text2.setEditable(false);this.add(text2);this.setVisible(true); /设置组件可见this.addWindowListener(new WinClose();/ 为框架注册窗口事件监听器,委托WinClose对象处置事件public v

16、oid actionPerformed(ActionEvent e) /单击事件处置方式,实现ActionListener接口String str =text1.getText();/取得文本行的字符串trylong num = Long.parseLong(str); / 将字符串转化成长整形text2.setText(yz(num);catch(NumberFormatException n)JOptionPane.showMessageDialog(this, +str+字符串不能转换成整数,请从头输入!);return; class WinClose implements Window

17、Listener /实现窗口事件监听器接口 public void windowClosing(WindowEvent e) / 窗口关闭事件处置方式System.exit(0); /程序运行终止 public void windowOpened(WindowEvent e) public void windowClosed(WindowEvent e) public void windowIconified(WindowEvent e) public void windowDeiconified(WindowEvent e) public void windowActivated(Windo

18、wEvent e) public void windowDeactivated(WindowEvent e) 假设文本行中的字符串不能转化成长整形,将弹出对话框“字符串不能转换成整数,请从头输入!;另外若是所输入的整数为小于等于2或大于2小于等于5也会弹出一个对话框“输入错误!必需是大于2的偶数或大于5的奇数!”(该窗口代码设置在yz()函数中)。trylong num = Long.parseLong(str);text2.setText(yz(num);catch(NumberFormatException n)JOptionPane.showMessageDialog(this, +st

19、r+字符串不能转换成整数,请从头输入!); 弹出对话框return;四、实验原始纪录(源程序、数据结构等)源程序如下import java.awt.*;import java.awt.event.*;import javax.swing.*;public class GDBH extends Frame implements ActionListenerprivate Button button;private TextField text1;private TextArea text2;public GDBH() super(验证哥德巴赫猜想); this.setBounds(450, 20

20、0, 350, 400); this.setResizable(false); this.setBackground(Color.lightGray); this.setLayout(new FlowLayout(); this.add(new Label(输入一个整数); text1=new TextField(,20); this.add(text1); button=new Button(验证哥德巴赫猜想); this.add(button); button.addActionListener(this); this.setLayout(new FlowLayout(); text2=n

21、ew TextArea(20,25); text2.setEditable(false); this.add(text2); this.setVisible(true); this.addWindowListener(new WinClose();public static void main(String args)new GDBH();public void actionPerformed(ActionEvent e)String str =text1.getText(); try long num = Long.parseLong(str);text2.setText(yz(num); catch(NumberFormatException n) JOptionPane.showMessageDialog(this, +str+字符串不能转换成整数,请从头输入!);return;public String yz(long num) String str1 = ; if(num2&num%2=0) for (long i = 2;i j5&num%2!=0) for(long i=2;inum;i+) for(long j=i;jnum;j+)

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1