java图形实验报告文档格式.docx
- 文档编号:4058413
- 上传时间:2023-05-02
- 格式:DOCX
- 页数:9
- 大小:16.56KB
java图形实验报告文档格式.docx
《java图形实验报告文档格式.docx》由会员分享,可在线阅读,更多相关《java图形实验报告文档格式.docx(9页珍藏版)》请在冰点文库上搜索。
jButton6=newjavax.swing.JButton();
jButton7=newjavax.swing.JButton();
jButton8=newjavax.swing.JButton();
jButton9=newjavax.swing.JButton();
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();
jButton1.setText("
3"
);
jButton1.addActionListener(newjava.awt.event.ActionListener(){
publicvoid
actionPerformed(java.awt.event.ActionEventevt){
jButton2.setText("
1"
jButton2.addActionListener(new});
}jButton1ActionPerformed(evt);
java.awt.event.ActionListener(){
jButton3.setText("
5"
jButton3.addActionListener(new});
}jButton2ActionPerformed(evt);
jButton4.setText("
2"
jButton4.addActionListener(new});
}jButton3ActionPerformed(evt);
jButton5.setText("
6"
});
}jButton4ActionPerformed(evt);
jButton5.addActionListener(newjava.awt.event.ActionListener(){
jButton6.setText("
8"
jButton6.addActionListener(new});
}jButton5ActionPerformed(evt);
jButton7.setText("
4"
jButton7.addActionListener(new});
}jButton6ActionPerformed(evt);
jButton8.setText("
7"
jButton8.addActionListener(new});
}jButton7ActionPerformed(evt);
jButton9.setText("
0"
jButton9.addActionListener(new});
}jButton8ActionPerformed(evt);
jButton10.setText("
9"
jButton10.addActionListener(new});
}jButton9ActionPerformed(evt);
jButton11.setText("
\u00f7"
jButton11.addActionListener(new});
}jButton10ActionPerformed(evt);
jButton12.setText("
\u00d7"
jButton12.addActionListener(new});
}jButton11ActionPerformed(evt);
jButton13.setText("
-"
jButton13.addActionListener(new});
}jButton12ActionPerformed(evt);
篇二:
JAVA实验报告
附件2:
实验报告封皮
20—学年第学期
课程
实验报告
学院:
运算机科学技术
专业:
软件工程
班级:
姓名:
学号:
任课教师:
王薇
实验日期:
XX年11月02日
-1-
-2-
实验日期:
XX年11月06日
-3-
-4-
篇三:
java图形用户界面实验报告
南京工程学院
课程名称JAVA基础
实验项目名称图形用户界面设计
实验学生班级
实验学生姓名
学号
同组学生姓名无
实验时刻XX年11月
实验地址
实验成绩评定
指导教师签字年月日
一、实验目的和要求
1.目的:
把握javaAWT及Swing组件的利用方式,包括窗口、框架、对话框、布局方式、面板、文本编辑器、按钮、组合框等,合理利用委托事件处置模型,把握不同组件,不同事件的事件处置方式,设计出能够响应事件的java图形用户界面。
2.要求:
设计图形用户界面,事件处置,异样处置并弹出对话框,提示从头输入信息。
二、实验题目
验证哥德巴赫猜想,添加图形用户界面
三、实验方式与步骤(需求分析、算法设计思路、流程图等)
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
publicclassGDBHextendsFrameimplementsActionListener//窗口框架响应单击事件,利用awt组件设计框架
{
privateButtonbutton;
//按钮
privateTextFieldtext1;
//文本行
privateTextAreatext2;
//文本区
publicGDBH()
super("
验证哥德巴赫猜想"
//设置框架窗口题目
this.setBounds(450,200,350,400);
//设置框架的位置和尺寸this.setResizable(false);
//设置框架大小不可改变this.setBackground(Color.lightGray);
//设置窗口背景颜色
this.setLayout(newFlowLayout());
//默许窗口流布局中对齐this.add(newLabel("
输入一个整数"
));
text1=newTextField("
"
20);
this.add(text1);
button=newButton("
this.add(button);
button.addActionListener(this);
//为按钮注册单击事件监听器,委托当前对象处置事件
//默许中对齐
text2=newTextArea(20,25);
text2.setEditable(false);
this.add(text2);
this.setVisible(true);
//设置组件可见
this.addWindowListener(newWinClose());
//为框架注册窗口事件监听器,委托WinClose对象处置事件
}
publicvoidactionPerformed(ActionEvente)//单击事件处置方式,实现ActionListener接口
Stringstr=text1.getText();
//取得文本行的字符串
try
longnum=Long.parseLong(str);
//将字符串转化成长整形
text2.setText(yz(num));
catch(NumberFormatExceptionn)
JOptionPane.showMessageDialog(this,"
\"
+str+"
字符串不能转换成整数,请从头输入!
!
return;
classWinCloseimplementsWindowListener//实现窗口事件监听器接口
publicvoidwindowClosing(WindowEvente)//窗口关闭事件处置方式
System.exit(0);
//程序运行终止
publicvoidwindowOpened(WindowEvente){}
publicvoidwindowClosed(WindowEvente){}
publicvoidwindowIconified(WindowEvente){}
publicvoidwindowDeiconified(WindowEvente){}
publicvoidwindowActivated(WindowEvente){}
publicvoidwindowDeactivated(WindowEvente){}
假设文本行中的字符串不能转化成长整形,将弹出对话框“字符串不能转换成整数,请从头输入!
;
另外若是所输入的整数为小于等于2或大于2小于等于5
也会弹出一个对话框“输入错误!
必需是大于2的偶数或大于5的奇数!
”(该窗口代码设置在yz()函数中)。
弹出对话框
四、实验原始纪录(源程序、数据结构等)
源程序如下
publicclassGDBHextendsFrameimplementsActionListener
super("
this.setBounds(450,200,350,400);
this.setResizable(false);
this.setBackground(Color.lightGray);
this.setLayout(newFlowLayout());
this.add(newLabel("
text1=newTextField("
this.add(text1);
button=newButton("
this.add(button);
button.addActionListener(this);
text2=newTextArea(20,25);
text2.setEditable(false);
this.add(text2);
this.setVisible(true);
publicstaticvoidmain(Stringargs[])
newGDBH();
publicvoidactionPerformed(ActionEvente)
try{longnum=Long.parseLong(str);
text2.setText(yz(num));
}catch(NumberFormatExceptionn){
publicStringyz(longnum)
Stringstr1="
if(num>
2&
&
num%2==0){for(longi=2;
i
j5&
num%2!
=0){for(longi=2;
i<
num;
i++){for(longj=i;
j<
j++){
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 图形 实验 报告
![提示](https://static.bingdoc.com/images/bang_tan.gif)