编程时钟代码 编程时钟代码怎么写

2025-04-06 14:37 - 立有生活网

ja编程利用按钮实现时钟的停止和开始功能(原代码)

package com.main;

编程时钟代码 编程时钟代码怎么写编程时钟代码 编程时钟代码怎么写


编程时钟代码 编程时钟代码怎么写


编程时钟代码 编程时钟代码怎么写


//仅供参考

import ja.awt.BorderLayout;

import ja.awt.nt.MouseAdapter;

import ja.awt.nt.MouseEvent;

import ja.awt.nt.MouseListener;

import jax.swing.JButton;

import jax.swing.JFrame;

import jax.swing.JTextArea;

public class Test extends JFrame{

/

@param args

/

Boolean flag = true;

JTextArea jta = new JTextArea();

JButton jb = new JButton("button");

public Test(){

jb.addMouseListener(new MouseAdapter(){

public void mouseClicked(MouseEvent e) {

if(flag){

flag = false;

}else{

flag = true;

}}

});

this.add(jta,BorderLayout.CENTER);

this.add(jb,BorderLayout.SOUTH);

this.setSize(300, 300);

this.setVisible(true);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

Thread thread = new Thread(new Runnable(){

@Override

public void run() {

int i = 0;

while(true){

if(flag){

i = i + 1;

jta.setText(i+"");

try {

Thread.currentThread().sleep(1000);

} catch (InterruptedException e) {

e.printStackTrace();

}}

}}

});

thread.start();

}public static void main(String[] args) {

Test test = new Test();

}}

怎么用C语言编程数字时钟

希望能帮到你

#include

#define uchar unsigned char

#define uint unsigned int

it w=P2^6; //位定义

it d=P2^7; //段定义

uchar a[]={0x3f,0x06,0x5b,0x4f,0x66,

0x6d,0x7d,0x07,0x7f,0x6f};

uchar hnum,fnum,mnum,num1,hshi,hge,fshi,fge,mshi,mge;

void delay(uint);

void display1(uchar,uchar,uchar,uchar,uchar,uchar);

void init();

void main()

{init();

while(1)

{display1(hshi,hge,fshi,fge,mshi,mge);

//display2(fshi,fge);

//display3(mshi,mge);

}}

/......初始化......./

void init()

{TMOD=1;

TH0=(65536-50000)/256;

TL0=(65536-50000)%256;

EA=1; // 开总中断

ET0=1; //开定时器0

TR0=1;//启动定时器0

}/......显示....../

void display1(uchar hshi,uchar hge,uchar fshi,uchar fge,uchar mshi,uchar mge)

{d=1;

P0=a[hshi];

d=0;

P0=0xff;

w=1;

P0=0xfe;

w=0;

delay(1);

d=1;

P0=a[hge];

d=0;

P0=0xff;

w=1;

P0=0xfd;

w=0;

delay(1);

d=1;

P0=a[fshi];

d=0;

P0=0xff;

w=1;

P0=0xf7;

w=0;

delay(1);

d=1;

P0=a[fge];

d=0;

P0=0xff;

w=1;

P0=0xef;

w=0;

delay(1);

d=1;

P0=a[mshi];

d=0;

P0=0xff;

w=1;

P0=0xbf;

w=0;

delay(1);

d=1;

P0=a[mge];

d=0;

P0=0xff;

w=1;

P0=0x7f;

w=0;

delay(1);

}/.....延时....../

void delay(uint z)

{uint i,j;

for(i=z;i>0;i--)

for(j=110;j>0;j--);

}/......中断....../

void T0_time() interrupt 1

{TH0=(65536-50000)/256;

TL0=(65536-50000)%256;

num1++;

if(num1==20)

{num1=0;

mnum++;

mshi=mnum/10;

mge=mnum%10;

if(mnum==60)

{mnum=0;

fnum++;

} fshi=fnum/10;

fge=fnum%10;

if(fnum==60)

{fnum=0;

hnum++;

}hshi=hnum/10;

hge=hnum%10;

if(hnum==24)

{hnum=0;

}}

}

C语言作业:结构体编程练习 在屏幕上模拟显示一个数字式时钟 源代码能给我的话+50,感谢

#include

struct clock {

int hour;

int minute;

int second;

};

typedef struct clock CLOCK;

/

函数功能:时、分、秒时间的更新

函数参数:无

函数返回值:无

/

void Update(CLOCK myclock) {

myclock->second++;

if (myclock->second == 60) { /若second值为60,表示已过1分钟,则 minute值加1/

myclock->second = 0;

myclock->minute++;

}if (myclock->minute == 60){ /若minute值为60,表示已过1小时,则 hour值加1/

myclock->minute = 0;

myclock->hour++;

}if (myclock->hour == 24) { /若hour值为24,则hour的值从0开始计时/

myclock->hour = 0;

}}

/

函数功能:时、分、秒时间的显示

函数参数:无

函数返回值:无

/

void Display(CLOCK myclock) { /用回车符'r'控制时、分、秒显示的位置/

printf("%2d:%2d:%2dr", myclock->hour, myclock->minute, myclock->second);

}/

函数功能:模拟延迟1秒的时间

函数参数:无

函数返回值:无

/

void Delay(void) {

long t;

for (t = 0; t < 290000000; t++) {

/循环体为空语句的循环,起延时作用/

}}

int main(){

CLOCK myclock;

long i;

myclock.hour = myclock.minute = myclock.second = 0; /hour,minute,second赋初值0/

for (i = 0; i < 100000; i++) { /利用循环结构,控制时钟运行的时间/

Update(&myclock); /时钟更新/

Display(&myclock); /时间显示/

Delay(); /模拟延时1秒/

}return 0;

}

#include

#include

#include

double seconds(void) {

strict rusage rusage;

if(!getrusage(RUSAGE_SELF, &rusage)) {

res += rusage.ru_utime.tv_sec + 1e-6 rusage.ru_utime.tv_usec;

res += rusage.ru_stime.tv_sec + 1e-6 rusage.ru_stime.tv_usec;

}return res;

}

用C#设计一个简易时钟

我设计了两个界面: 代码如下:using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;namespace WindowsFormsApplication1

{public partial class MainFrm : Form

{//计时功能,初始化系统时间

public int Hours { get; set; }

public int Minutes { get; set; }

public int Seconds { get; set; }

public string nowdate { get; set; } private void Ticking()

{Seconds++;

if (Hours > 23)

{Hours = 0;

Minutes = 0;

Seconds = 0;

}else if (Minutes > 59)

{Hours += 1;

Minutes = 0;

Seconds = 0;

}else if (Seconds > 59)

{Minutes += 1;

Seconds = 0;

}} public MainFrm()

{InitializeComponent();

} private void timer1_Tick(object sender, EventArgs e)

{label1.Text = "当前日期:" + nowdate + "n";

label1.Text += string.Format("{0:0#}:{1:0#}:{2:0#}", Hours, Minutes, Seconds);

Ticking();

} private void button1_Click(object sender, EventArgs e)

{(new SettingFrm(this)).ShowDialog();

} private void MainFrm_Load(object sender, EventArgs e)

{Hours = DateTime.Now.Hour;

Minutes = DateTime.Now.Minute;

Seconds = DateTime.Now.Second;

nowdate = DateTime.Today.ToLongDateString();

}}

}using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;namespace WindowsFormsApplication1

{public partial class SettingFrm : Form

{private MainFrm _mf = null; public SettingFrm(MainFrm mf):this()

{_mf = mf;

timeBox.Text = mf.Hours + ":" + mf.Minutes + ":" + mf.Seconds;

dateTimePicker1.Text = mf.nowdate;

}public SettingFrm()

{InitializeComponent();

} private void SettingFrm_Load(object sender, EventArgs e)

{ } private void button1_Click(object sender, EventArgs e)

{_mf.nowdate = dateTimePicker1.Text;

string[] time = timeBox.Text.Split(':');

_mf.Hours = Convert.ToInt32(time[0]);

_mf.Minutes = Convert.ToInt32(time[1]);

_mf.Seconds = Convert.ToInt32(time[2]);

this.Close();

}}

}

VB程序设计怎么做数字时钟

提供一个思路,就是用一张BMP的素材,上面有各种数字的。

使用时,用API裁剪出上面的某个数字,显示到DC里(就是PictureBOX之类)。

依这个思路我用VC6的MFC实现过……

Private Sub Form_Load()

Timer1.Interval = 1000

Label1.Caption = Time

End Sub

Private Sub Timer1_Timer()

Label1.Caption = Time

End Sub

vnc远程控制软件(vnc远程控制软件 手机版)

vnc远程控制软件跨网段怎么应用? 一般来说VNC跨网段通常可以运用在内网的机器,内网机器可以进行一个很好的连接.比如利用VNC的可以批量进行作内网机器,即可实现VNC跨网段的应用.如果在windows系···

用侧面描写写一个人(用侧面描写写一个人唱歌

关于用侧面描写写一个人,用侧面描写写一个人唱歌好听这个很多人还不知道,今天小天来为大家解答以上的问题,现在让我们一起来看看吧! 用侧面描写写一个人(用侧面描写写一个人唱歌好听···

标题:探索令人上瘾的类似英雄联盟的游戏世

英雄联盟(League of Legends)无疑是当今的多人在线战斗竞技场 (MOBA) 游戏之一。它以其复杂的角色、战略游戏和团队战的而闻名。如果您正在寻找类似的体验,以下是值得一试的几款游戏: 标题:探···