ssd4实验五实验报告_第1页
ssd4实验五实验报告_第2页
ssd4实验五实验报告_第3页
ssd4实验五实验报告_第4页
ssd4实验五实验报告_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、实验五1、 实验目的 为进入时区编写一个接口程序2、 实验内容 将世界地图载入界面,通过下拉列表控件对时区进行选择,并在地图中显示,如下图(1)主界面 (2)点击OK出现的界面 3、 实验步骤1. 实验代码package mycode;import javax.swing.JOptionPane;/* * * author Administrator */public class exercise5 extends javax.swing.JFrame /* Creates new form exercise5 */ public exercise5() this.setResizable(f

2、alse); initComponents(); this.setTitle(TIME/DATE);/设置标题 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 v

3、oid initComponents() jComboBox1 = new javax.swing.JComboBox(); jPanel1 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jCheckBox1 = new javax.swing.JCheckBox(); jLabel2 = new javax.swing.JLabel(); setDefaul

4、tCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String (GMT -12:00) Eniwetok, Kwajalein , (GMT -11:00) Midway Island, Samoa , (GMT -10:00) Hawaii , (GMT -09:00) Alaska , (GMT -08:00) Pacific Time (US and Canada); Tijuana , (GMT

5、 -07:00) Arizona , (GMT -07:00) Mountain Time (US and Canada) , (GMT -06:00) Central Time (US and Canada) , (GMT -06:00) Mexico City, Tegucigalpa , (GMT -06:00) Saskatchewan , (GMT -05:00) Bogota, Lima , (GMT -05:00) Eastern Time (US and Canada) , (GMT -05:00) Indiana (East) , (GMT -04:00) Atlantic

6、Time (Canada) , (GMT -04:00) Caracas, La Paz , (GMT -03:30) Newfoundland , (GMT -03:00) Brasilia , (GMT -03:00) Buenos Aires, Georgetown , (GMT -02:00) Mid-Atlantic , (GMT -01:00) Azores, Cape Verde Is. , (GMT +00:00) Greenwich Mean Time; Dublin, Edinburgh, London, Lisbon , (GMT +00:00) Monrovia, Ca

7、sablanca , (GMT +01:00) Berlin, Stockhold, Rome, Bern, Brussels, Vienna , (GMT +01:00) Paris, Madrid, Amsterdam , (GMT +01:00) Prage, Warsaw, Budapest , (GMT +02:00) Athens, Helsinki, Istanbul , (GMT +02:00) Cairo , (GMT +02:00) Eastern Europe , (GMT +02:00) Harare, Pretoria , (GMT +02:00) Israel ,

8、(GMT +03:00) Baghdad, Kuwait, Nairobi, Riyadh , (GMT +03:00) Moscow, St. Petersburgh, Kazan, Volgograd , (GMT +03:00) Tehran , (GMT +04:00) Abu Dhabi, Muscat, Tbilisi , (GMT +04:30) Kabul , (GMT +05:00) Islamabad, Karachi, Ekaterinburg, Tashkent , (GMT +05:30) Bombay, Calcutta, Madras, New Delhi, Co

9、lombo , (GMT +06:00) Almaty, Dhaka , (GMT +07:00) Bangkok, Jakarta, Hanoi , (GMT +08:00) Beijing, Chongqing, Urumqi , (GMT +08:00) Hong Kong, Perth, Singapore, Taipei , (GMT +09:00) Tokyo, Osaka, Sapporo, Seoul, Yakutsk , (GMT +09:30) Adelaide (GMT +09:30) Darwin , (GMT +10:00) Brisbane, Melbourne,

10、Sydney , (GMT +10:00) Guam, Port Moresby, Vladivostok , (GMT +10:00) Hobart , (GMT +11:00) Magadan, Solomon Is., New Caledonia , (GMT +12:00) Fiji, Kamchatka, Marshall Is. , (GMT +12:00) Wellington, Auckland ); jComboBox1.setBorder(javax.swing.BorderFactory.createCompoundBorder(); jComboBox1.addActi

11、onListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jComboBox1ActionPerformed(evt); ); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layou

12、t.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 9, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 168, Short.MAX_VALUE) ); jButton1.setText(OK); jButton1.addActionListener(new jav

13、a.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jButton1ActionPerformed(evt); ); jButton2.setText(CANCEL); jButton3.setText(APPLY); jCheckBox1.setText(Automaticlly adjust clock for daynight saving changes); jCheckBox1.setEnabled(false); jCheckBox1.addActionLi

14、stener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) jCheckBox1ActionPerformed(evt); ); jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource(/mycode/无标题.png); / NOI18N jLabel2.setText(jLabel2); javax.swing.GroupLayout layout = new javax.s

15、wing.GroupLayout(getContentPane(); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L

16、EADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 429, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_

17、VALUE) .addGroup(layout.createSequentialGroup() .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .add

18、Gap(13, 13, 13) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(129, 129, 129) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponen

19、t(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(35, 35, 35) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jCheckBox1, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.M

20、AX_VALUE) .addContainerGap() ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swi

21、ng.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupL

22、ayout.PREFERRED_SIZE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 168, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCheckBox1) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL

23、INE) .addComponent(jButton1) .addComponent(jButton2) .addComponent(jButton3) .addContainerGap(66, Short.MAX_VALUE) ); pack(); / private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) selectnum = jComboBox1.getSelectedIndex(); selectstr = jComboBox1.getSelectedItem().toString(); for(i

24、nt i=0;iselectnum;i+) jLabel2.setLocation(jLabel2.getLocation().x+20, jLabel2.getLocation().y); private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) / TODO add your handling code here: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) / TODO add your handling cod

25、e here: String str = Time set to n; str +=n; str +=Timezone=; str += selectstr; str +=noffset from GMT =; String str1 =String.format(%d, selectselectnum); str += str1; str +=n Auto daynight =Falsen; str +=; JOptionPane.showMessageDialog(null, str); /* * param args the command line arguments */ public static void main(String args) java.awt.EventQueue.invoke

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论