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

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

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

    用JAVA做小時鐘

    Posted on 2006-09-03 07:08 久城 閱讀(1007) 評論(0)  編輯  收藏 所屬分類: JavaTest

    學JAVA 做的第一個GUI程序......
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;

    class Clock extends JFrame
    {
    ?public static double PI = 3.14159265;
    ?Calendar now;
    ?int hh;
    ?int mm;
    ?int ss;
    ?Clock()
    ?{
    ??super("我的時鐘");
    ??setSize(400,400);
    ??setVisible(true);
    ?}
    ?public void paint(Graphics g)
    ?{
    ??g.setColor(Color.WHITE);
    ??g.fillRoundRect(100,100,200,200,200,200);
    ??g.setColor(Color.BLACK);
    ??g.drawString("1",(int)(200-2+100*(Math.sin(30*2*PI/360))),(int)(200+10-100*(Math.cos(30*2*PI/360))));
    ??g.drawString("2",(int)(200-6+100*(Math.sin(30*2*2*PI/360))),(int)(200+10-100*(Math.cos(30*2*2*PI/360))));
    ??g.drawString("3",(int)(200-7+100*(Math.sin(30*3*2*PI/360))),(int)(200-100*(Math.cos(30*3*2*PI/360))));
    ??g.drawString("4",(int)(200-6+100*(Math.sin(30*4*2*PI/360))),(int)(200-100*(Math.cos(30*4*2*PI/360))));
    ??g.drawString("5",(int)(200-2+100*(Math.sin(30*5*2*PI/360))),(int)(200-2-100*(Math.cos(30*5*2*PI/360))));
    ??g.drawString("6",(int)(200+100*(Math.sin(30*6*2*PI/360))),(int)(200-100*(Math.cos(30*6*2*PI/360))));
    ??g.drawString("7",(int)(200+100*(Math.sin(30*7*2*PI/360))),(int)(200-100*(Math.cos(30*7*2*PI/360))));
    ??g.drawString("8",(int)(200+100*(Math.sin(30*8*2*PI/360))),(int)(200-100*(Math.cos(30*8*2*PI/360))));
    ??g.drawString("9",(int)(200+100*(Math.sin(30*9*2*PI/360))),(int)(200-100*(Math.cos(30*9*2*PI/360))));
    ??g.drawString("10",(int)(200+2+100*(Math.sin(30*10*2*PI/360))),(int)(200+2-100*(Math.cos(30*10*2*PI/360))));
    ??g.drawString("11",(int)(200+100*(Math.sin(30*11*2*PI/360))),(int)(200+10-100*(Math.cos(30*11*2*PI/360))));
    ??g.drawString("12",(int)(200+100*(Math.sin(30*12*2*PI/360))),(int)(200+10-100*(Math.cos(30*12*2*PI/360))));
    ??g.setColor(Color.RED);

    ??Calendar now=Calendar.getInstance();
    ??int hh=now.get(Calendar.HOUR_OF_DAY);//小時
    ??int mm=now.get(Calendar.MINUTE);//分鐘
    ??int ss=now.get(Calendar.SECOND);// 秒
    ??g.drawLine(200,200,(int)(200+90*(Math.sin(6*ss*2*PI/360))),(int)(200-90*(Math.cos(6*ss*2*PI/360)))); //畫秒針
    ??g.setColor(Color.black);
    ??g.drawLine(200,200,(int)(200+70*(Math.sin(6*mm*2*PI/360))),(int)(200-70*(Math.cos(6*mm*2*PI/360))));//畫分針
    ??g.setColor(Color.blue);
    ??g.drawLine(200,200,(int)(200+50*(Math.sin((30*hh+0.5*mm)*2*PI/360))),(int)(200-50*(Math.cos((30*hh+0.5*mm)*2*PI/360)))); //畫時針
    ??try{Thread.sleep(500);}catch(Exception e){}
    ??repaint();??
    ?}

    ?public static void main(String[] args)
    ?{
    ??
    ??Clock c = new Clock();
    ??c.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ??
    ?}
    }



    歡迎來訪!^.^!
    本BLOG僅用于個人學習交流!
    目的在于記錄個人成長.
    所有文字均屬于個人理解.
    如有錯誤,望多多指教!不勝感激!

    Copyright © 久城

    主站蜘蛛池模板: 美女扒开屁股让男人桶爽免费| 亚洲Av无码精品色午夜| 亚洲综合男人的天堂色婷婷| 特a级免费高清黄色片| 免费毛片在线看片免费丝瓜视频 | 巨胸狂喷奶水视频www网站免费| 亚洲精品无码一区二区| 在线观看人成网站深夜免费| 国产hs免费高清在线观看| 亚洲AV成人精品网站在线播放| 亚洲一区二区三区国产精品| 亚洲色大情网站www| 99爱在线精品免费观看| 亚洲视频在线观看免费视频| 日本黄色动图免费在线观看| 国产成人高清亚洲| 亚洲AV女人18毛片水真多| 成人免费观看一区二区| 亚洲国产人成网站在线电影动漫 | 亚洲18在线天美| 国产亚洲精品仙踪林在线播放| 无码精品人妻一区二区三区免费| igao激情在线视频免费| 一区二区三区免费视频观看| 国产精品黄页在线播放免费| 国产成人综合久久精品亚洲| 国产亚洲AV手机在线观看| 无码免费一区二区三区免费播放| 亚洲国产成人久久一区WWW| 中出五十路免费视频| 亚洲第一区香蕉_国产a| 永久免费AV无码国产网站| 美女被免费视频网站| 亚洲AV成人片色在线观看高潮| eeuss影院www天堂免费| 国产V亚洲V天堂无码久久久| 国产成人免费高清激情明星| 无码一区二区三区亚洲人妻| 亚洲AV乱码久久精品蜜桃| 妞干网免费观看视频| 美女视频黄a视频全免费网站色窝|