《SSD4实验四实验报告.doc》由会员分享,可在线阅读,更多相关《SSD4实验四实验报告.doc(7页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、实验四一、 实验目的1. 编写程序界面,可以调节时间2. 编写UAR报告二、 实验内容1. 模拟以下界面,要求数字能在1-59间调节2. 对以下界面编写UAR报告三、 实验步骤1. 第一部分 实验代码 * exercise4.java * Created on 2012-11-22, 15:25:45package mycode;import java.util.Calendar; * author Administratorpublic class exercise4 extends javax.swing.JFrame /* Creates new form exercise4 */ pu
2、blic exercise4() initComponents(); hour = Integer.parseInt(jLabel1.getText(); minutes=Integer.parseInt(jLabel2.getText(); seconds=Integer.parseInt(jLabel3.getText(); /* This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this
3、 method is * always regenerated by the Form Editor. SuppressWarnings(unchecked) / private void initComponents() jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jButto
4、n2 = 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 = new javax.swing.JButton(); jButton9 = new javax.swing.JButton(); se
5、tDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setBackground(java.awt.Color.gray); setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR); jPanel1.setBackground(java.awt.Color.lightGray); jLabel1.setFont(new java.awt.Font(宋体, 1, 36); / NOI18N jLabel1.setText(0); jLabel2.se
6、tFont(new java.awt.Font(宋体, 1, 36); / NOI18N jLabel2.setText(0); jLabel3.setFont(new java.awt.Font(宋体, 1, 36); / NOI18N jLabel3.setText(0); jButton1.setFont(new java.awt.Font(宋体, 0, 24); / NOI18N jButton1.setText(OK); jButton1.addActionListener(new java.awt.event.ActionListener() public void actionP
7、erformed(java.awt.event.ActionEvent evt) jButton1ActionPerformed(evt); jButton2.setFont(new java.awt.Font(宋体, 1, 18); / NOI18N jButton2.setText(cancel); jButton2.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton2ActionPerformed(
8、evt); jButton3.setFont(new java.awt.Font(宋体, 1, 18); / NOI18N jButton3.setText(Apply); jButton3.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton3ActionPerformed(evt); jButton4.setText(+); jButton4.addActionListener(new java.awt
9、.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton4ActionPerformed(evt); jButton5.setText(-); jButton5.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton5ActionPerformed(evt); jButton6.set
10、Text(+); jButton6.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton6ActionPerformed(evt); jButton7.setText(-); jButton7.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent
11、 evt) jButton7ActionPerformed(evt); jButton8.setText(+); jButton8.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton8ActionPerformed(evt); jButton9.setText(-); jButton9.addActionListener(new java.awt.event.ActionListener() public
12、 void actionPerformed(java.awt.event.ActionEvent evt) jButton9ActionPerformed(evt); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
13、ADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(53, 53, 53) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout
14、.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addCompon
15、ent(jButton4) .addGap(21, 21, 21) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGro
16、up(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.create
17、ParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequen
18、tialGroup() .addGap(11, 11, 11) .addComponent(jButton2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabe
19、l3, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_
20、SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton8) .addContainerGap(63, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(19, 19, 19) .addComponent(jButton3) .addContainerGap() jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(
21、javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(62, 62, 62) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(2, 2, 2) .addGroup(jPan
22、el1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.
23、PREFERRED_SIZE) .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButt
24、on5, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SI
25、ZE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jButton8) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton9) .addComponent(jLabel3) .addGap(89, 89, 89) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
26、.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE) .
27、addContainerGap(47, Short.MAX_VALUE) javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane(); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFA
28、ULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) pack(); / private void j
29、Button4ActionPerformed(java.awt.event.ActionEvent evt) / TODO add your handling code here: hour=hour+1; if(24=hour) hour=0; jLabel1.setText(String.valueOf(hour); private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) / TODO add your handling code here: hour=hour-1; if(-1=hour) hour=23;
30、 jLabel1.setText(String.valueOf(hour); private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) / TODO add your handling code here: minutes=minutes+1; if(60=minutes) minutes=0; jLabel2.setText(String.valueOf(minutes); private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) /
31、 TODO add your handling code here: minutes=minutes-1; if(-1=minutes) minutes=59; jLabel2.setText(String.valueOf(minutes); private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) / TODO add your handling code here: seconds=seconds+1; if(60=seconds) seconds=0; jLabel3.setText(String.value
32、Of(seconds); private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) / TODO add your handling code here: seconds=seconds-1; if(-1=seconds) seconds=59; jLabel3.setText(String.valueOf(seconds); private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) / TODO add your handling c
33、ode here: time.set(2012, 11, 22, hour, minutes, seconds); private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) / TODO add your handling code here: System.exit(0); private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) / TODO add your handling code here: jLabel1.setText(
34、0); jLabel2.setText(0); jLabel3.setText(0); * param args the command line arguments public static void main(String args) java.awt.EventQueue.invokeLater(new Runnable() public void run() new exercise4().setVisible(true); / Variables declaration - do not modify private javax.swing.JButton jButton1; pr
35、ivate javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton7; private javax.swing.JButton jButton8; private javax.swing.JButton jButton9
36、; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPanel jPanel1; / End of variables declaration private int hour ; private int minutes; private int seconds; private Calendar time; 实验截图2. 第二部分UAR报告 界面简介该用户界面是一个声音调节的应用程序界
37、面,其主体部分布局在一个属性页中,划分为3个主题部分,分别为event、sounds、schemes.在属性页底部设置了3个按钮,有OK、CANCEL、APPLY。 界面分析a. 在event部分,有一个带有滚动条的列表框控件构成,其内容是有关电脑操作的各种事件,其可供点击选择,而滚动条的设置使得小的界面上能够容纳更多的内容b. 在sounds部分,有用来选择音乐文件的下拉列表,还提高了browser按钮和detail按钮,能提供用户个性化的选择。右边可以试听播放所选音乐文件,更增强了与用户的互动性,使用户更加方便c. 对于底端的3个按钮,是windows操作系统的经典风格,会使用户产生熟悉感