<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    java 計時器
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;


    public class Miao extends JFrame implements ActionListener
    {
     JButton button1;
     JButton button2;
     JTextField  tf;
     JPanel panel;
        Timer time;
        int shu=0;
        int miao=0;
        int minute=0;
        int hour;
        int day;
        int year;
        int century;
        JLabel label;
     

     /**
      * Method actionPerformed
      *
      *
      * @param e
      *
      */
      public Miao()
      {
       
       
       this.xian();
       this.addlistener();
       
      }
      public void xian()
      {
       panel = new JPanel();
       time         = new Timer(1,this);
       label = new JLabel("0");
       this.button1 = new JButton("開始");
       this.button2 = new JButton("停止");
       this.tf      = new JTextField(30);
       panel.add(label);
       System.out.println ("label-width"+this.label.getWidth()+"");
       System.out.println ("label-height"+this.label.getHeight()+"");
       panel.add(tf);
       panel.add(this.button1);
       panel.add(this.button2);
       this.getContentPane().add(panel);
       this.setBounds(200,20,350,350);
       this.setVisible(true);
       this.setTitle("計數器");
      }
      public void addlistener()
      {
       this.button1.addActionListener(this);
       this.button2.addActionListener(this);
         // time.addActionListener(this);
     
      }
     
     public void actionPerformed(ActionEvent e)
     {
      // TODO: Add your code heree.getSource()==this.button1
     
      if(e.getSource()==this.button1)
      {
       System.out.println ("開始");
       this.shu=0;
       this.miao=0;
       this.minute=0;
       this.hour=0;
       this.day=0;
       this.year=0;
       this.century=0;
       this.tf.setText(0+"");
       time.start();
          
      }
      if(e.getSource()==this.button2)
      {
       System.out.println ("停止");
       time.stop();
      }
      if(e.getSource()==time)
      {
     // System.out.println ("time");
      this.shu++;
     // System.out.println (shu);
     
     
       this.tf.setText(this.century+"世紀"+this.year+"年"+this.day+"日"+this.hour+":"+minute+":"+miao+":"+shu+"");
       //label.setText(shu+"");
       if(shu%100==0)
       {
        this.shu=0;
        this.miao++;
       // tf.setText(minute+":"+miao+":"+shu);
        System.out.println ("label-width"+this.label.getWidth()+"");
         System.out.println ("label-height"+this.label.getHeight()+"");
         if(this.miao%60==0)
         {
          this.miao=0;
          this.minute++;
          if(this.minute%60==0)
          {
           this.minute=0;
           this.hour++;
           if(this.hour%24==0)
           {
            this.hour=0;
            this.day++;
            if(this.day%365==0)
            {
             this.year++;
             this.day=0;
             if(this.year%100==0)
             {
              this.year=0;
              this.century++;
             }
            }
           }
          }
          
         }
       }
     
      
      
      }
      
     }
     public static void main(String as[])
      {
       new Miao();
      }
    }

    posted on 2011-07-02 23:47 sanmao 閱讀(221) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    常用鏈接

    留言簿(5)

    隨筆分類

    隨筆檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲女人初试黑人巨高清| 伊人久久亚洲综合| 亚洲AV无码乱码麻豆精品国产| 国产99视频精品免费专区| 亚洲精品无码av人在线观看| 天堂亚洲免费视频| 亚洲男人av香蕉爽爽爽爽| 伊人久久国产免费观看视频| 亚洲日韩在线第一页| 久久免费观看视频| 亚洲av无码一区二区三区不卡 | 四虎成人精品国产永久免费无码 | AAAAA级少妇高潮大片免费看| 狠狠色婷婷狠狠狠亚洲综合| 一级毛片免费播放视频| 亚洲综合伊人久久大杳蕉| a级片在线免费看| 99人中文字幕亚洲区| 免费A级毛片无码无遮挡内射| 亚洲日本va一区二区三区| 国产大片免费观看中文字幕| 免费一区二区无码视频在线播放| 亚洲不卡无码av中文字幕| 中国毛片免费观看| 亚洲白色白色在线播放| 好男人www免费高清视频在线| 在线观看免费亚洲| 亚洲精品无码久久久久sm| 在线观看免费视频资源| 亚洲Av永久无码精品黑人| 亚洲男同帅GAY片在线观看| 久久久久国产精品免费网站| 亚洲成A人片在线播放器| 亚洲精品久久久www| 67pao强力打造国产免费| 精品亚洲福利一区二区| 亚洲国产成人一区二区三区| 无码专区永久免费AV网站 | 午夜免费福利视频| 亚洲人av高清无码| 亚洲电影一区二区三区|