java 时钟 算法分析,Java版世界时钟示例

这是一个Java版的世界时钟示例,移植自Gerrit创建的同名Swing应用(http://www.jug-muenster.de/swing-worldclock-427

),需要运行在JRE1.5或以上环境当中。

移植此示例主要是因为前一阵移植过Gerrit的swing原子钟示例,所谓好事成双,这个世界时钟的示例自然不能放过(话说Gerrit为什么那么喜欢做时钟?……),毕竟Java桌面应用实例本就不多,但凡有参考价值的还是要多做汇总才好。

另外,此示例中关于多时区的分辨与显示部分,在非桌面应用中也具备一定的参考价值。

PS:由于此示例以LGame-Simple-0.2.5开发,所以也可以看作是世界时钟的AWT实现。

下载地址(源码在jar中):http://loon-simple.googlecode.com/files/WorldClock.7z

运行代码如下所示(构建过程省略了Swing原版的一些步骤):

package org.loon.test;

import java.awt.Graphics2D;

import java.awt.event.KeyEvent;

import java.awt.event.MouseEvent;

import java.awt.image.BufferedImage;

import org.loon.framework.game.simple.GameScene;

import org.loon.framework.game.simple.core.graphics.Deploy;

import org.loon.framework.game.simple.core.graphics.Screen;

import org.loon.framework.game.simple.utils.GraphicsUtils;

/**

* Copyright 2008 - 2009

*

* Licensed under the Apache License, Version 2.0 (the "License"); you may not

* use this file except in compliance with the License. You may obtain a copy of

* the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT

* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the

* License for the specific language governing permissions and limitations under

* the License.

*

* @project loonframework

* @author chenpeng

* @email:ceponline@yahoo.com.cn

* @version 0.1

*/

public class Main extends Screen {

// 此示例移植自http://www.jug-muenster.de/swing-worldclock-427/同名应用

public Main() {

// 设置窗体背景

this.setBackground(createBackgroundImage());

// 创建时间精灵

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值