Java窗体版时间显示功能小时钟.rar

u735696828 22 0 RAR 2019-09-24 21:09:43

Java窗体版时间显示功能-小时钟,简单的说下原理,通过调用paint方法进行界面重绘,然后重载组件的paint方法,得到Graphics2D对象,最后实例化日历对象得到时、分、秒,格式化输出,相关代码如下:  publicvoidpaint(Graphicsg){//重载组件的paint方法  Graphics2Dg2=(Graphics2D)g;//得到Graphics2D对象  Calendarnow=newGregorianCalendar();//实例化日历对象  StringtimeInfo="";//输出信息  inthour=now.get(Calendar.HOUR_OF_D

用户评论
请输入评论内容
评分:
暂无评论