SSD4实验六实验报告.doc

上传人:文库蛋蛋多 文档编号:2887972 上传时间:2023-03-01 格式:DOC 页数:25 大小:332.50KB
返回 下载 相关 举报
SSD4实验六实验报告.doc_第1页
第1页 / 共25页
SSD4实验六实验报告.doc_第2页
第2页 / 共25页
SSD4实验六实验报告.doc_第3页
第3页 / 共25页
SSD4实验六实验报告.doc_第4页
第4页 / 共25页
SSD4实验六实验报告.doc_第5页
第5页 / 共25页
点击查看更多>>
资源描述

《SSD4实验六实验报告.doc》由会员分享,可在线阅读,更多相关《SSD4实验六实验报告.doc(25页珍藏版)》请在三一办公上搜索。

1、实验六一、 实验目的编写一个完整的DATE/TIME选择界面,能实现时间,时区选择对windows显示属性界面进行分析,写出UAR报告二、 实验内容编写以下程序项目,并包含以下内容要求: The second setting (0 to 59) The minute setting (0 to 59) The hour setting (in 24 hour time, 0 to 23) The day of the month The month of the year The year The index of the currently selected time zone The of

2、fset in minutes from GMT for the currently-selected time zone The title of the currently selected time zone 样例界面:对以下界面进行界面分析三、 实验步骤实验代码/* * To change this template, choose Tools | Templates * and open the template in the editor. */* * exercise5B.java * * Created on 2012-12-2, 16:13:25 */package myco

3、de;import java.awt.BasicStroke;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Component;import java.awt.Graphics;import java.awt.Graphics2D;import java.util.Calendar;import java.util.GregorianCalendar;import java.util.TimerTask;import javax.swing.ButtonGroup;import javax.swing.JL

4、abel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JSpinner;import javax.swing.JTable;import javax.swing.SpinnerNumberModel;import javax.swing.table.AbstractTableModel;import javax.swing.table.TableCellRenderer; / Variables declaration - do not modify / Variables declar

5、ation - do not modify/* * * author Administrator */public class exercise5B extends javax.swing.JFrame /* Creates new form exercise5B */ public exercise5B() calendar = Calendar.getInstance(); amorpm = calendar.get(Calendar.AM_PM);/获取当天是在上午还是下午 initComponents(); x=jLabel1.getLocation().x; y=jLabel1.ge

6、tLocation().y; selectnum = -1; /* This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ SuppressWarnings(unchecked) / private void initComponents() jButton1 = new javax

7、.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); jSpinner1 = new javax.swing.JSpinner(); jScrollPane1

8、 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jComboBox2 = new javax.swing.JComboBox(); jPanel5 = new javax.swing.JPanel(); jSpinner2 = new JSpinner(new SpinnerNumberModel(1,1,12,1); jSpinner3 = new JSpinner(new SpinnerNumberModel(1,0,59,1); jSpinner4 = new JSpinner(new Spinn

9、erNumberModel(1,0,59,1); jRadioButton1 = new javax.swing.JRadioButton(); jRadioButton2 = new javax.swing.JRadioButton(); jPanel6 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jComboBox1 = new javax.swing.JComboBox(); jPanel3 = new javax.swing.JPa

10、nel(); jLabel1 = new javax.swing.JLabel(); jCheckBox1 = new javax.swing.JCheckBox(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle(TIME/DATE); jButton1.setBackground(new java.awt.Color(153, 153, 153); jButton1.setFont(new java.awt.Font(宋体, 0, 14); jButton1.setText(ok)

11、; jButton1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED); jButton1.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton1ActionPerformed(evt); ); jButton2.setBackground(new java.awt.Col

12、or(153, 153, 153); jButton2.setFont(new java.awt.Font(宋体, 0, 14); jButton2.setText(cancel); jButton2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED); jButton2.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event

13、.ActionEvent evt) jButton2ActionPerformed(evt); ); jButton3.setBackground(new java.awt.Color(153, 153, 153); jButton3.setFont(new java.awt.Font(宋体, 0, 14); / NOI18N jButton3.setText(apply); jButton3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED); jButton

14、3.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton3ActionPerformed(evt); ); jLabel3.setFont(new java.awt.Font(宋体, 0, 14); jLabel3.setText(Ponze Exampe); jTabbedPane1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.s

15、wing.border.BevelBorder.RAISED, null, java.awt.Color.darkGray, null, null); jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(Date&Time); jPanel4.setFont(new java.awt.Font(宋体, 0, 14); jSpinner1.setEditor(new JSpinner.NumberEditor(jSpinner1, 0000); jSpinner1.setValue(new Integer(calendar

16、.get(Calendar.YEAR); jSpinner1.addChangeListener(new javax.swing.event.ChangeListener() public void stateChanged(javax.swing.event.ChangeEvent evt) jSpinner1StateChanged(evt); ); jScrollPane1.setPreferredSize(new java.awt.Dimension(45, 40); daysModel =new AbstractTableModel() public int getRowCount(

17、) return 6; public int getColumnCount() return 7; public String getColumnName(int col) switch (col) case 0: return WEEK_SUN; case 1: return WEEK_MON; case 2: return WEEK_TUE; case 3: return WEEK_WED; case 4: return WEEK_THU; case 5: return WEEK_FRI; case 6: return WEEK_SAT; default: return null; /设置

18、日期在哪显示 public Object getValueAt(int row, int column) / row-; Calendar calendar = (Calendar) exercise5B.this.calendar.clone(); calendar.set(Calendar.DAY_OF_MONTH, 1); int dayCount = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); int moreDayCount = calendar.get(Calendar.DAY_OF_WEEK) - 1; int index

19、= row * 7 + column; int dayIndex = index - moreDayCount + 1; if (index dayCount) return null; else return new Integer(dayIndex); ; jTable1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0); jTable1.setModel(daysModel); jTable1.setCellSelectionEnabled(true); jTable1.set

20、ShowHorizontalLines(false); jTable1.setShowVerticalLines(false); jTable1.setDefaultRenderer(jTable1.getColumnClass(0), new TableCellRenderer() public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) String text = (value =

21、null) ? : value.toString(); daystr =text;/获取选择的日期 JLabel cell = new JLabel(text); cell.setOpaque(true); if (row = -1) cell.setForeground(headerForeground); cell.setBackground(headerBackground); else if (isSelected) cell.setForeground(selectedForeground); cell.setBackground(selectedBackground); else

22、cell.setForeground(foreground); cell.setBackground(background); return cell; ); jScrollPane1.setViewportView(jTable1); jComboBox2.setEditable(true); jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String January , February , Marcy , April , May , June , July , August , September , Octob

23、er , November , December , ); jComboBox2.setSelectedIndex(calendar.get(Calendar.MONTH); jComboBox2.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jComboBox2ActionPerformed(evt); ); javax.swing.GroupLayout jPanel4Layout = new javax.sw

24、ing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupL

25、ayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE) .addGroup(jPanel4Layout.createSequentialGroup() .addComponent(jComboBox2, 0, 117, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.Com

26、ponentPlacement.UNRELATED) .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap() ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSeq

27、uentialGroup() .addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBox2, javax.swi

28、ng.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(42, Short.MAX_VALUE) ); jPanel5.setBorder(javax.swing.BorderFactory.createT

29、itledBorder(null, Time, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font(宋体, 0, 14); / NOI18N jPanel5.setPreferredSize(new java.awt.Dimension(231, 231); jSpinner2.setEditor(new JSpinner.NumberEditor(jSpinner2, 00); if(amorpm=C

30、alendar.AM) jSpinner2.setValue(new Integer(calendar.get(Calendar.HOUR); else jSpinner2.setValue(new Integer(calendar.get(Calendar.HOUR); jSpinner2.addChangeListener(new javax.swing.event.ChangeListener() public void stateChanged(javax.swing.event.ChangeEvent evt) jSpinner2StateChanged(evt); ); jSpin

31、ner3.setEditor(new JSpinner.NumberEditor(jSpinner3, 00); jSpinner3.setValue(new Integer(calendar.get(Calendar.MINUTE); jSpinner4.setEditor(new JSpinner.NumberEditor(jSpinner4, 00); jSpinner4.setValue(new Integer(calendar.get(Calendar.SECOND); jRadioButton1.setText(AM); group.add(jRadioButton1); jRad

32、ioButton2.setText(PM); group.add(jRadioButton2); jPanel6.setLayout(new java.awt.GridLayout(1, 0); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayou

33、t.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap() .addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.sw

34、ing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(14, 14, 14) .addComponent(jSpinner4, javax.swing.GroupLayout.PREFERRED_SIZE, 38,

35、 javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jRadioButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jRadioButton2, javax.swin

36、g.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel5Layout.createSequentialGroup() .addGap(30, 30, 30) .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(18, Short.MAX_VALUE) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel6, javax.swing.GroupLayout.DEFA

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号