文档来源为:从网络收集整理.word版本可编辑.欢迎下载支持.
java图形实验报告
篇一:java实验报告实验六Java图形用户界面 信 息 工 程 学 院 Java程序设计 实习报告 JAVA图形用户界面 实验六Java图形用户界面 1.实验目的
(1)掌握图形用户界面基本组件。
(2)了解如何使用布局管理器对组件进行管理。 (3)掌握Java事件处理机制。 2.实验内容
实验题1 编写一个模拟计算器的程序,使用面板和网格布局,添加一个文本框,10个数字按钮(0-9),4个加减乘除按钮,一个等号按钮,一个清除按钮,要求将计算公式和结果显示在文本框中。 运行结果:
实验报告的内容与格式按任课教师的要求书写。 加法: 主要代码:
private void initComponents() {
setStub(null); jButton1 = new ; jButton2 = new ; jButton3 = new ; jButton4 = new ; jButton5 = new ;
1文档来源为:从网络收集整理.word版本可编辑.
文档来源为:从网络收集整理.word版本可编辑.欢迎下载支持.
jButton6 = new ; jButton7 = new ; jButton8 = new ; jButton9 = new ; jButton10 = new ; jButton11 = new ; jButton12 = new ; jButton13 = new ; jButton14 = new ; jButton15 = new ; jTextField1 = new ;
jButton1.setText(\
jButton1.addActionListener(new { public void
actionPerformed( evt) {
jButton2.setText(\
}
jButton2.addActionListener(new}); jButton1ActionPerformed(evt); { public void
actionPerformed( evt) {
jButton3.setText(\
}
jButton3.addActionListener(new}); jButton2ActionPerformed(evt); { public void
actionPerformed( evt) {
jButton4.setText(\
}
jButton4.addActionListener(new}); jButton3ActionPerformed(evt); { public void
2文档来源为:从网络收集整理.word版本可编辑.
文档来源为:从网络收集整理.word版本可编辑.欢迎下载支持.
actionPerformed( evt) {
jButton5.setText(\
}
jButton4ActionPerformed(evt); jButton5.addActionListener(new { public void
actionPerformed( evt) {
jButton6.setText(\
}
jButton6.addActionListener(new}); jButton5ActionPerformed(evt); { public void
actionPerformed( evt) {
jButton7.setText(\
}
jButton7.addActionListener(new}); jButton6ActionPerformed(evt); { public void
actionPerformed( evt) {
jButton8.setText(\
}
jButton8.addActionListener(new}); jButton7ActionPerformed(evt); { public void
actionPerformed( evt) {
jButton9.setText(\
3文档来源为:从网络收集整理.word版本可编辑.
相关推荐: