package com.xx.watch;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.xx.bird.World;
/**
*Cacth.java
*com.xx.cacth
*工程:bird
*功能:TODO
*author date time
*李星星 2014-2-27 下午5:09:42
*Email:hai5253@163.com
*copytight (C) 2014 ,INI All Rights Reserved.
*/
public class Watch extends JPanel{
BufferedImage bimg;
FZ fz;
SZ sz;
MZ mz;
int x,y;
public Watch (){
try {
bimg = ImageIO.read(getClass().getResource("ss.gif"));
x = bimg.getWidth();
y = bimg.getHeight();
Date date = new Date();
SimpleDateFormat m = new SimpleDateFormat("s");
SimpleDateFormat f = new SimpleDateFormat("m");
SimpleDateFormat s = new SimpleDateFormat("H");
double mm =Double.valueOf(m.format(date));
double ff = Double.valueOf(f.format(date))+mm/60;
double ss = Double.valueOf(s.format(date))+ff/60;
mz = new MZ(x,y,mm);
fz = new FZ(x, y,ff);
sz = new SZ(x,y,ss);
} catch (IOException e) {
e.printStackTrace();
}
}
public void paint(Graphics g){
Graphics2D g2 = (Graphics2D)g;
RenderingHints qualityHints = new RenderingHints(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
qualityHints.put(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
g2.setRenderingHints(qualityHints);
g.drawImage(bimg, 0, 0, null);
// g.setColor(Color.red);
// g.drawLine(x/2, 0, x/2, y);
// g.drawLine(0, y/2, x, y/2);
SimpleDateFormat f = new SimpleDateFormat("yyyy年MM月dd日 E");
Font font = new Font(Font.MONOSPACED,Font.BOLD,12);
g.setFont(font);
g.setColor(Color.red);
g.drawString(f.format(new Date()), 35, 10);
fz.paint(g);
sz.paint(g);
mz.paint(g);
}
public void action() throws InterruptedException{
while(true){
repaint();
mz.step();
fz.step();
sz.step();
Thread.sleep(1000);
}
}
public static void main(String[] args) throws IOException, InterruptedException {
JFrame frame = new JFrame("时钟");
Watch watch = new Watch();
frame.add(watch);
frame.setSize(watch.x+5,watch.y+30);
frame.setResizable(false);//可变大小
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
watch.action();
}
}
最近下载更多
Willson88888 LV3
2022年12月7日
飘逸人 LV4
2022年11月17日
mannka LV2
2022年6月28日
Demo1111 LV30
2021年12月12日
最代码-宋家辉 LV61
2021年11月30日
woaini001987 LV1
2020年11月16日
谷凤宇 LV10
2020年5月29日
wei112233 LV15
2020年4月2日
15966848095 LV22
2020年1月12日
y1214435276 LV9
2019年9月25日
最近浏览更多
2636804923 LV6
2024年6月20日
微信网友_7034311029100544
2024年6月12日
暂无贡献等级
2046577244
2024年6月12日
暂无贡献等级
drawing
2023年11月6日
暂无贡献等级
qq1434100519 LV1
2023年11月1日
2385649653 LV7
2023年6月25日
aweixianng
2023年6月24日
暂无贡献等级
WZXYYS
2023年6月5日
暂无贡献等级
SILKYYY
2023年5月25日
暂无贡献等级
111168
2023年5月21日
暂无贡献等级

