为了方便大家copy,我就不分段解释了
import turtle, random
# 定义一个类,用来画除了数字方块之外的图形
class BackGround(turtle.Turtle):
def __init__(self):
super().__init__()
self.penup()
self.ht()
def draw_block(self):
self.shape('bg.gif') # 画出背景方块
for i in allpos:
self.goto(i)
self.stamp()
self.color('white', 'white') # 画出其他背景
self.goto(-215, 120)
self.begin_fill()
self.goto(215, 120)
self.goto(215, 110)
self.goto(-215, 110)
self.end_fill()
self.shape('title.gif')
self.goto(-125, 210)
self.stamp()
self.shape('score.gif')
self.goto(125, 245)
self.stamp()
self.shape('top_score.gif')
self.goto(125, 170)
self.stamp()
# 游戏失败及达成2048的提示文字
def judge(self):
global flag_win, flag_win_lose_text
self.color('blue')
judge = 0 # 判断是否还有位置可以移动
for i in block_dic.values():
for j in block_dic.values():
if i.num == 0 or i.num == j.num and i.distance(j) == 100:
judge += 1
if judge == 0: # 无位置可移动,游戏失败
self.write(' GAME OVER\n重新开始请按空格键', align='center', font=('黑体', 30, 'bold'))
flag_win_lose_text = False
if flag_win is True: # 此条件让2048达成的判断只能进行一次
for k in block_dic.values():
if k.num == 2048: # 游戏达成
flag_win = False
self.write(' 达成2048\n继续游戏请按回车键', align='center', font=('黑体', 30, 'bold'))
flag_win_lose_text = False
def win_lose_clear(self):
global flag_win_lose_text
self.clear()
flag_win_lose_text = True
def show_score(self): # 分值的显示
global score, top_score
if score >top_score:
top_score = score
with open('.\\score.txt', 'w') as f:
f.write(f'{top_score}')
self.color('white')
self.goto(125, 210)
self.clear()
self.write(f'{score}', align='center', font=('Arial', 20, 'bold'))
self.goto(125, 135)
self.write(f'{top_score}', align='center', font=('Arial', 20, 'bold'))
# 数字方块类
class Block(turtle.Turtle):
def __init__(self):
super().__init__()
self.ht()
self.penup()
self.num = 0
def draw(self):
self.clear()
dic_draw = {2: '#eee6db', 4: '#efe0cd', 8: '#f5af7b',
16: '#fb9660', 32: '#f57d5a', 64: '#f95c3d',
128: '#eccc75', 256: '#eece61', 512: '#efc853',
1024: '#ebc53c', 2048: '#eec430', 4096: '#aeb879',
8192: '#aab767', 16384: '#a6b74f'}
if self.num >0: # 数字大于0,画出方块
self.color(f'{dic_draw[self.num]}') # 选择颜色
self.begin_fill()
self.goto(self.xcor()+48, self.ycor()+48)
self.goto(self.xcor()-96, self.ycor())
self.goto(self.xcor(), self.ycor()-96)
self.goto(self.xcor()+96, self.ycor())
self.goto(self.xcor(), self.ycor()+96)
self.end_fill()
self.goto(self.xcor()-48, self.ycor()-68)
if self.num >4: # 按照数字选择数字的颜色
self.color('white')
else:
self.color('#6d6058')
self.write(f'{self.num}', align='center', font=('Arial', 27, 'bold'))
self.goto(self.xcor(), self.ycor()+20)
class Game():
def init(self):
back = BackGround() # 实例画出游戏的背景
back.draw_block()
for i in allpos: # 画出16个海龟对应16个数字块
block = Block()
block.goto(i)
block_dic[i] = block
game.grow()
def restart(self): # 重开游戏的方法
global score, flag_win_lose_text
score = 0
for i in block_dic.values():
i.num = 0
i.clear()
win_lose_text.clear()
game.grow()
flag_win_lose_text = True # 此flag为游戏达成或失败出现提示语后的判断,要提示语被clear后才能继续move
def grow(self): # 随机出现一个2或4的数字块
block_list = []
for i in allpos:
if block_dic[i].num == 0:
block_list.append(block_dic[i]) # 挑出空白方块的海龟
turtle_choice = random.choice(block_list) # 随机选中其中一个海龟
turtle_choice.num = random.choice([2, 2, 2, 2, 4]) # 赋属性num=2/4
turtle_choice.draw()
win_lose_text.judge()
show_score_text.show_score()
ms.update()
def move_up(self):
allpos1 = allpos[::4] # 切片为四列
allpos2 = allpos[1::4]
allpos3 = allpos[2::4]
allpos4 = allpos[3::4]
self.move_move(allpos1, allpos2, allpos3, allpos4)
def move_down(self):
allpos1 = allpos[-4::-4]
allpos2 = allpos[-3::-4]
allpos3 = allpos[-2::-4]
allpos4 = allpos[-1::-4]
self.move_move(allpos1, allpos2, allpos3, allpos4)
def move_left(self):
allpos1 = allpos[:4]
allpos2 = allpos[4:8]
allpos3 = allpos[8:12]
allpos4 = allpos[12:16]
self.move_move(allpos1, allpos2, allpos3, allpos4)
def move_right(self):
allpos1 = allpos[-1:-5:-1]
allpos2 = allpos[-5:-9:-1]
allpos3 = allpos[-9:-13:-1]
allpos4 = allpos[-13:-17:-1]
self.move_move(allpos1, allpos2, allpos3, allpos4)
def move_move(self, allpos1, allpos2, allpos3, allpos4):
if flag_win_lose_text is True:
count1 = self.move(allpos1) # 四列或四行依次移动
count2 = self.move(allpos2)
count3 = self.move(allpos3)
count4 = self.move(allpos4)
if count1 or count2 or count3 or count4: # 判断是否有方块移动,有才能继续出现新的数字块
self.grow()
def move(self, pos_list):
num_list = [] # 为某一列或行的数字块海龟的坐标
for i in pos_list:
num_list.append(block_dic[i].num) # 把这些海龟的NUM形成list
new_num_list, count = self.list_oper(num_list) # 只是list_oper的方法形成新的list
for j in range(len(new_num_list)): # 把新的list依次赋值给对应的海龟.num属性并调用draw()方法
block_dic[pos_list[j]].num = new_num_list[j]
block_dic[pos_list[j]].draw()
return count
def list_oper(self, num_list): # num_list的 *** 作,假设其为【2,0,2,2】
global score
count = True
temp = []
new_temp = []
for j in num_list:
if j != 0:
temp.append(j) # temp=[2,2,2]
flag = True
for k in range(len(temp)):
if flag:
if k <len(temp)-1 and temp[k] == temp[k+1]:
new_temp.append(temp[k]*2)
flag = False
score += temp[k]
else:
new_temp.append(temp[k]) # new_temp=[4,2]
else:
flag = True
for m in range(len(num_list)-len(new_temp)):
new_temp.append(0) # new_temp=[4,2,0,0]
if new_temp == num_list:
count = False # 此变量判断num_list没有变化,数字块无移动
return(new_temp, count)
if __name__ == '__main__':
ms = turtle.Screen() # 主窗口的设置
ms.setup(430, 630, 400, 50)
ms.bgcolor('gray')
ms.title('2048')
ms.tracer(0)
ms.register_shape('bg.gif')
ms.register_shape('title.gif')
ms.register_shape('score.gif')
ms.register_shape('top_score.gif')
block_dic = {} # 放数字方块海龟的字典,位置坐标为key,对应海龟为value
allpos = [(-150, 50), (-50, 50), (50, 50), (150, 50),
(-150, -50), (-50, -50), (50, -50), (150, -50),
(-150, -150), (-50, -150), (50, -150), (150, -150),
(-150, -250), (-50, -250), (50, -250), (150, -250)]
flag_win = True # 达成2048的判断,让达成的文字仅出现一次
flag_win_lose_text = True # 用来判断失败或成功的提示文字是否有被清除,不清除不能继续移动方块
score = 0
with open('.\\score.txt', 'r') as f:
top_score = int(f.read()) # 读取score中的数据
show_score_text = BackGround()
win_lose_text = BackGround()
game = Game()
game.init()
ms.listen()
ms.onkey(game.move_up, 'Up')
ms.onkey(game.move_down, 'Down')
ms.onkey(game.move_left, 'Left')
ms.onkey(game.move_right, 'Right')
ms.onkey(win_lose_text.win_lose_clear, 'Return')
ms.onkey(game.restart, 'space')
ms.mainloop()
这是游戏界面:
欢迎挑战最高分。
要运行出来,必须本地要有这些文件:bg.gif,score.gif,title.gif,top_score.gif,score.txt
我把这些文件放在了群里,还有一些学习的资料,群号642109462,欢迎对python感兴趣的进群讨论。
支持作者的,可以关注和点赞。感谢你们!
java编写时钟程序_Java实现时钟小程序 原创2021-02-17 00:47:37
无可就是九头鸟
码龄6年
关注
哎,好久没上博客园发东西了,上一次还是两个月前的五一写的一篇计算器博客,不过意外的是那个程序成了这学期的Java大作业,所以后来稍微改了一下那个程序就交了上去,这还是美滋滋。然后五月中旬的时候写了一个2048小游戏,由于写完第二个版本第二天就生病了,休养了好几天才缓过来,最后嫌麻烦就没发园子里了,直接挂Github上了。然后又忙着准备期末,期末玩休息了5天又开始数据库课程设计,用Java写了一个小系统,花了一个星期左右,写了差不多3500行了。然后写完就放学了,放学的日子就感觉自己开始懒散了,静不下心来写东西,每天睡觉,看一些无聊的视频。。。前几天算是缓过神来,找回了脑子,于是又开始想着在放弃Java之前再多写一点东西,于是花了两个下午写了一个时钟,感觉看着还行。
-----------------------------------以下是正经话-----------------------------------
其实这个程序并不难,主要是用Java 2D画图,弄一个线程,每隔一秒,依照时针分针秒针各自的速度重新计算它们走过的角度(相对12点方向顺时针偏离的角度),利用这个角度算出它们各自端点的坐标,重绘一次表针,达到刷新的目的,最后时限走动的效果,思路很简单,清晰明了。但是关键是这个画图呀,想着很容易,重写继承过来的JFrame里的paint函数就行,最后发现效果并不是期待的那样,而是一闪一闪的,于是去寻找原因,结果,尼玛,原来水这么深,一下子触到了知识盲区,什么repaint的实现细节,先调用update,再调用paint,update函数又是如何工作的,慢慢弄懂了它为什么会一闪一闪的原因,然后寻找解决办法,然后就看到了什么双缓冲原理,WTF!什么玩意呀,根本没听过,然后乖乖地去看那东西的实现原理,又看到有人建议不要去重写paint方法,说是会遇到诸多意想不到的问题,建议去重写paintComponent方法,可是书本上画图的例子都是重写paint方法呀,况且我也没听过paintComponent,无奈,又去看了一下paint的工作原理,原来它会调用paintComponent,最后放弃了自己实现双缓冲,乖乖改用了paintComponent。。。
其实我还遇到了几个脑残的问题,比如在画秒针时,直接把画时针的部分代码复制下来,最后忘了改掉走动的速度,结果运行时还在想秒针怎么走不动呢?原谅我是个逗逼,还有什么秒针逆时针走动,最后才发现算坐标时误把y轴正方向当成了向上,哎。。。
Anyway,最后运行的效果还是挺好的
3c55d177347f0c89c364f17fe0859265.png
-----------------------------------以下是代码-----------------------------------
1 import java.awt.*2 importjava.util.Date3 import javax.swing.*4
5 public class Clock extendsJComponent{6 /**
7 *8 */
9 private static final long serialVersionUID = -5379472973578609775L10 private Font f = new Font("微软雅黑",Font.PLAIN,15)11 private Font f2 = new Font("微软雅黑",Font.BOLD,15)12 private JLabel l = new JLabel("当前时间:")13 private JLabel display = newJLabel()14 private JLabel display2 = new JLabel("")15 private int hour = 016 private int min = 017 private int sec = 018 private Date now = newDate()19 privateGraphics2D g20 final double PI =Math.PI21 private String strTime = ""22
23 @SuppressWarnings("deprecation")24 publicClock(){25 add(l)26 l.setBounds(120, 320, 80, 20)27 l.setFont(f)28 add(display)29 display.setBounds(195, 320, 80, 20)30 display.setFont(f)31 display.setBorder(BorderFactory.createLineBorder(Color.black))32 add(display2)33 display2.setBounds(90, 350, 250, 20)34 display2.setFont(f)35 hour =now.getHours()36 min =now.getMinutes()37 sec =now.getSeconds()38 setVisible(true)39 }40
41 public voidpaintComponent(Graphics g1){42 doublex,y43 super.paintComponent(g1)44 g =(Graphics2D) g145 //反锯齿开关开
46 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)47
48 //画表盘
49 g.setPaint(new GradientPaint(5,40,Color.blue,15,50,Color.yellow,true))50 g.setStroke( new BasicStroke(3,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL))51 g.drawOval(75, 40, 250, 250)52 g.fillOval(195, 160, 10, 10)53 g.setColor(Color.black)54
55 //画60个点
56 for(int i = 0i <60i++)57 {58 double[] co = new double[2]59 co = paint_Dot(i * 2 * PI / 60)60 x = co[0]61 y = co[1]62 if(i == 0 || i == 15 || i == 30 || i == 45)//画3,6,9,12四个大点
63 {64 g.fillOval((int)(x - 5 + 200),(int)(y - 5 + 165),10,10)65 }66 else//其他小点
67 {68 g.fillOval((int)(x - 2.5 + 200),(int)(y - 2.5 + 165),5,5)69 }70 }71
72 //画四个数字
73 g.setFont(f2)74 g.drawString("3", 300, 171)75 g.drawString("6", 195, 273)76 g.drawString("9", 91, 171)77 g.drawString("12", 190, 68)78
79 //画时针,分针,秒针
80 paint_HourPointer(hour*3600 + min*60 + sec,g)//时针走过的秒数
81 paint_MinutePointer(min*60 + sec,g)//分针走过的秒数
82 paint_SecondPointer(sec,g)//秒针走过的秒数
83 }84
85 public voidshowUI(){86 newThread() {87 @SuppressWarnings("deprecation")88 public voidrun() {89 while (true)90 {91 now = newDate()92 hour =now.getHours()93 min =now.getMinutes()94 sec =now.getSeconds()95 try{96 Thread.sleep(1000)97 } catch(InterruptedException ex) {98 ex.printStackTrace()99 }100 showTime()101 repaint()102 }103 }104 }.start()105 }106
107 public void paint_HourPointer(int second,Graphics2D g){//second表示当前时间的时针相对00:00:00走了多少秒
108 doublex,y,angle109 angle = second * PI / 21600//时针的速度为PI/21600 (rad/s)
110 x = 200 + 60 *Math.sin(angle)111 y = 165 - 60 *Math.cos(angle)112 g.setStroke( new BasicStroke(5,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND))113 g.setPaint(new GradientPaint(200,165,Color.red,260,165,Color.blue,true))114 g.drawLine(200, 165, (int)x, (int)y)115 }116
117 public void paint_MinutePointer(int second,Graphics2D g){//second表示当前时间的分针相对00:00:00走了多少秒
118 doublex,y,angle119 angle = second * PI / 1800//分针的速度为PI/1800 (rad/s)
120 x = 200 + 80 *Math.sin(angle)121 y = 165 - 80 *Math.cos(angle)122 g.setStroke( new BasicStroke(3,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND))123 g.setPaint(new GradientPaint(200,165,Color.magenta,280,165,Color.blue,true))124 g.drawLine(200, 165, (int)x, (int)y)125 }126
127 public void paint_SecondPointer(int second,Graphics2D g){//second表示当前时间的秒针相对00:00:00走了多少秒
128 doublex,y,x1,y1,x2,y2,x3,y3,angle129 double cos = 90 / Math.sqrt(8125)//90*90+5*5
130 double sin = 5 / Math.sqrt(8125)131 angle = second * PI / 30//时针的速度为PI/30 (rad/s)
132 x = 200 + 95 *Math.sin(angle)133 y = 165 - 95 *Math.cos(angle)134 x1 = 200 + 20 * Math.sin(angle +PI)135 y1 = 165 - 20 * Math.cos(angle +PI)136 x2 = 200 + Math.sqrt(8125)* ( Math.sin(angle)*cos - Math.cos(angle)*sin )//sin(a-b)
137 y2 = 165 - Math.sqrt(8125)* ( Math.cos(angle)*cos + Math.sin(angle)*sin )//cos(a-b)
138 x3 = 200 + Math.sqrt(8125)* ( Math.sin(angle)*cos + Math.cos(angle)*sin )//sin(a+b)
139 y3 = 165 - Math.sqrt(8125)* ( Math.cos(angle)*cos - Math.sin(angle)*sin )//cos(a+b)
140 g.setStroke( new BasicStroke(2,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL))141 g.setPaint(new GradientPaint(180,165,Color.CYAN,295,165,Color.MAGENTA,true))142 g.drawLine((int)x1, (int)y1, (int)x, (int)y)143 g.drawLine((int)x2, (int)y2, (int)x, (int)y)144 g.drawLine((int)x3, (int)y3, (int)x, (int)y)145 }146
147 public double[] paint_Dot(doubleangle){148 double[] co = new double[2]149 co[0] = 115 * Math.cos(angle)//横坐标
150 co[1] = 115 * Math.sin(angle)//纵坐标
151 returnco152 }153
154 @SuppressWarnings("deprecation")155 private voidshowTime(){156 String date157 int hour_temp = hour,min_temp = min,sec_temp =sec158 sec_temp += 1159 if(sec_temp >= 60)160 {161 sec_temp = 0162 min_temp += 1163 }164 if(min_temp>=60){165 min_temp=0166 hour_temp+=1167 }168 if(hour_temp <10)169 strTime = "0" + hour_temp + ":"170 else
171 strTime = "" + hour_temp + ":"172
173 if(min_temp <10)174 strTime = strTime + "0" + min_temp + ":"175 else
176 strTime = strTime + "" + min_temp + ":"177
178 if(sec <10)179 strTime = strTime + "0" +sec_temp180 else
181 strTime = strTime + "" +sec_temp182 //在窗体上设置显示时间
183 date = " " + (now.getYear()+1900) + "年" + (now.getMonth()+1) + "月" + now.getDate() + "日 " + "星期"184 switch(now.getDay()) {185 case 1:186 date += "一"187 break188 case 2:189 date += "二"190 break191 case 3:192 date += "三"193 break194 case 4:195 date += "四"196 break197 case 5:198 date += "五"199 break200 case 6:201 date += "六"202 break203 case 7:204 date += "日"205 break206 }207 date += " CST"208 strTime = " " +strTime209 display.setText(strTime)210 display2.setText(date)211 }212
213 public static voidmain(String args[]){214 Clock c = newClock()215 c.showUI()216 JFrame f = new JFrame("Clock By XJX")217 Image img=Toolkit.getDefaultToolkit().getImage("title.gif")//窗口图标
218 f.setIconImage(img)219 f.setSize(400,400)220 f.setResizable(false)221 f.add(c, BorderLayout.CENTER)222 f.setLocationRelativeTo(null)223 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)224 f.setVisible(true)225 }226 }
相关资源:...仿真和代码)_51单片机做实时时钟显示-小程序文档类资源-CSDN文库
文章知识点与官方知识档案匹配
Java技能树首页概览
91513 人正在系统学习中
打开CSDN APP,看更多技术内容
不会编程也能亲手编写一个桌面数字小时钟程序,仅3步轻松实现_程序员笑...
第一步 打开电脑自带的记事本并编写以下脚本。 源码: @echo off Title 小时钟丨编程狮(w3cschool.cn) @mode con cols=50lines=5color00:main cls echo.echo 时间:%time%echo.echo 日期:%date%echo.ping-n20.0.0.0>nulgotomain ...
继续访问
OpenGL织梦之旅【第二章】编写一个的钟表程序_plusplus7的博客-CSDN...
在配置好了glut环境以后,运行了第一个opengl程序以后,我们现在就来尝试编写一个实用一点的程序——时钟程序。 如图: 制作这样一个程序,对于初学者来说,感觉上或许很难,但是只要我们一步一步地慢慢来,总会有熟练掌握的那一天。“包子要...
继续访问
Java时钟程序(绘制了一个带时针 分针 秒针的仿真时钟)
这是我自己写的一个java时钟程序 当然你可以自己改动 喜欢就拿去吧
Java时钟小程序
Java时钟小程序,可以显示出当前的系统时间,
java 钟_JAVA时钟 - 代码块 - 扣丁书屋 - https://www.codingsky.com
import javax.swing.*import java.awt.*import java.util.*import java.lang.Threadimport java.text.DecimalFormatpublic class DongClock extends JPanel {/*** @param args*/private int hourprivate int m...
继续访问
使用eclipse设计开发的安卓软件,闹钟定时器
使用eclipse开发的安卓软件--闹钟定时器,学生开发的小作业。 学生党可以下载参考的软件,首次学习,还在很多的不足,不喜勿喷,谢谢!
java 电子时钟_Java电子时钟实现代码
用Java编写一个程序,实现动态的文字时钟,以秒计时。知识点:1、线程(Thread)2、Applet类:它最先执行iniy()方法,完成后进入初始态;然后马上执行start()方法,Applet程序进入运行状态;线程也在start()中被启动,然后执行run()中的内容。当Applet程序所在的浏览器图标化或者转入其他页面时,Applet程序马上执行stop()方法3、Java不像C++,只能...
继续访问
java时钟_Java实现时钟小程序
哎,好久没上博客园发东西了,上一次还是两个月前的五一写的一篇计算器博客,不过意外的是那个程序成了这学期的Java大作业,所以后来稍微改了一下那个程序就交了上去,这还是美滋滋。然后五月中旬的时候写了一个2048小游戏,由于写完第二个版本第二天就生病了,休养了好几天才缓过来,最后嫌麻烦就没发园子里了,直接挂Github上了。然后又忙着准备期末,期末玩休息了5天又开始数据库课程设计,用Java写了一个小...
继续访问
java 简易时钟
简易时钟演示图一、界面设计二、获取时间与设置时间三、完整代码总结 演示图 非常质朴的时钟 一、界面设计 JFrame app=new JFrame("电子闹钟")Container c=app.getContentPane()//设置一个面板容器 面板为初始设置面板 JLabel clock=new JLabel("电子闹钟")clock.setHorizontalTextPosition(JLabel.CENTER)/.
继续访问
时钟程序设计java_Java数字时钟实现代码详解
这是一个数字钟表程序,主要功能是从系统中获取当前的系统时间然后再将其显示在数字时钟上,由于整个的数字时钟都是用函数构成的,所以它可以实现一般的数 字时钟所不具有的功能,比如说它可以被鼠标指针拖动到窗口的任意位置,除此之外它还可以实现钟表大小随鼠标滚轮的滚动而变大变小的 *** 作。package TheClockimport java.awt.*import javax.swing.*import ...
继续访问
钟表java程序教程 创建_JAVA--编写时钟的程序
代码如下:import java.awt.*import java.text.DateFormatimport java.util.*import javax.swing.*public class ClockDemo extends JFrame implements Runnable{Thread clockfinal int Xpoint=180final int Ypoint=...
继续访问
java时钟代码_JAVA实现时钟
时钟题目内容:在课程所给的时钟程序的基础上修改。这一周的编程题是需要你在课程所给的时钟程序的基础上修改而成。但是我们并不直接给你时钟程序的代码,请根据视频自己输入时钟程序的Display和Clock类的代码,然后来做这个题目。我们需要给时钟程序加上一个表示秒的Display,然后为Clock增加以下public的成员函数:public Clock(int hour, int minute, int...
继续访问
JAVA实现时钟
时钟 题目内容: 在课程所给的时钟程序的基础上修改。 这一周的编程题是需要你在课程所给的时钟程序的基础上修改而成。但是我们并不直接给你时钟程序的代码,请根据视频自己输入时钟程序的Display和Clock类的代码,然后来做这个题目。 我们需要给时钟程序加上一个表示秒的Display,然后为Clock增加以下public的成员函数: public Clock(int hour, i...
继续访问
java gui 做闹钟,用JAVA怎样编写一个可以在eclipse中运行的闹钟程序?
首先java程序的运行你需要下载和安装JDK,这是java运行的必备环境。首先你要在桌面上找到是eclipes,双击打开。在eclipes启动的过程中,会d出一个窗口,让你填写java工作区的保存目录,在这个目录下会保存你写的所有的源代码文件,小编建议你不要把工作区放在C盘,你如果重装系统的话,源代码就会全部损失。ecplies启动完成之后,会有一个欢迎页面,这个不用管,直接点击左上方的差号,取消...
继续访问
自定义时钟控件
通过继承View类,我们可以自定义自己需求的复杂控件。本例实现了一个自定义的时钟。 效果如下: 代码如下: package com.example.testimport java.util.Calendarimport android.content.Contextimport android.graphics.Bitmapimport android.gra
继续访问
java时钟课程设计,Java课程设计-时钟图形模拟
《Java课程设计-时钟图形模拟》由会员分享,可在线阅读,更多相关《Java课程设计-时钟图形模拟(19页珍藏版)》请在人人文库网上搜索。1、课 程 设 计 任 务 书专 业通信工程班 级13级四班姓 名张凯铭设 计 起 止 日 期设计题目:时钟图形模拟设计任务(主要技术参数):硬件环境:CPU:Pentium 2.8GHz以上 内存:256MB以上 硬盘空间:80G以上软件环境:(1) *** 作系统:...
继续访问
最新发布 用Java编写一个时钟
public class Display { private int value=0private int limate=0public void increase() { value++if(value==limate) { value=0} } public int getvalue() { return value} Display(int limate){ this.limate=limate} } public clas.
继续访问
java编写时钟程序_Java编写时钟 Applet 程序
简单分析:package clockAppletimport java.applet.Appletimport java.awt.Colorimport java.awt.Graphicsimport java.util.Calendarimport java.util.GregorianCalendarpublic class ClockApplet extends Applet i...
继续访问
java 画图板源代码_非常值得学习的java 绘图板源代码
package minidrawpadimport java.awt.BasicStrokeimport java.awt.Colorimport java.awt.Fontimport java.awt.Graphics2Dimport java.io.Serializable//图形绘制类 用于绘制各种图形//父类,基本图形单元,用到串行的接口,保存使用到//公共的属性放到超类中,...
继续访问
Eclipse编写的Android数字时钟应用实例(用新建Runnable的方法)
Eclipse V4.2.0用新建Runnable的方法编写的Android数字时钟应用实例。
java时钟日历_java日历时钟小程序
java日历时钟小程序 java日历时钟小程序 Java时钟程序,按类粘贴至编译器编译即可使用。 import java.awt.BorderLayoutimport java.awt.Colorimport java.awt.GridLayoutimport java.awt.event.ActionEventimport java.awt.event.ActionListene...
继续访问
java显示一个钟表_java实现时钟效果
本文实例为大家分享了java实现时钟效果的具体代码,供大家参考,具体内容如下实现效果如图:Java代码:文件一:ClockPanel.javaimport static java.util.Calendar.HOURimport static java.util.Calendar.MILLISECONDimport static java.util.Calendar.MINUTEimport...
继续访问
时钟程序很难做吗
java编写时钟程序
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)