求用JAVA编程制作可以分组记录秒表数据的功能 30
求用JAVA编程制作可以分组记录秒表数据的功能(点一次计时记录一次数据,在文本区显示出来),并且可以显示时间,修改时间,还有闹铃功能。求完整的程序,谢谢。我指的记录多组数...
求用JAVA编程制作可以分组记录秒表数据的功能(点一次计时记录一次数据,在文本区显示出来),并且可以显示时间,修改时间,还有闹铃功能。求完整的程序,谢谢。
我指的记录多组数据是相当于6人同时百米赛跑,用一个秒表可以记录6个人的成绩 展开
我指的记录多组数据是相当于6人同时百米赛跑,用一个秒表可以记录6个人的成绩 展开
展开全部
参考下这里的时钟吧,这是一个能在JFrame上显示当前时间的表,并且能随着时间的流动,一秒一秒的移动秒针.如果你想更美观一点还可以在表的中间加一些时间数字.希望能对你有帮助.
-----------------------------Clock.java-----------
import java.awt.*;
public class Clock {
private int hour;
private int minute;
private int second;
public Clock(){
}
public Clock(int hrs,int min,int sec){
hour =hrs % 12;
minute = min;
second = sec;
}
void show (Graphics g,int cx,int cy,int rad){
int hourLenght = (int)(rad * 0.5);//时针的长度
int minuteLenght = (int)(rad * 0.6);//分针的长度
int secondLenght = (int)(rad * 0.9);//秒针的长度
double angle;//角度
//画出钟面
g.drawOval(cx-rad, cy - rad, rad * 2, rad * 2);
//画出时针
angle = (double)(hour*60*60 + minute*60 + second)/43200.0*2.0*Math.PI;
drawNiddle(g,Color.blue, cx, cy, hourLenght,angle);
//画分针
angle = (double)(minute*60 + second)/3600 * 2.0 * Math.PI;
drawNiddle(g,Color.blue, cx, cy, minuteLenght,angle);
// 画秒针
angle = (double)(second)/60*2.0*Math.PI;
drawNiddle(g,Color.blue, cx, cy, secondLenght,angle);
}
private void drawNiddle(Graphics g ,Color c,int x,int y,int len,double angle){
int ex = (int)(x + len * Math.sin(angle));
int ey = (int)(y - len * Math.cos(angle));
g.setColor(c);
g.drawLine(x,y,ex,ey);
}
}
----------------ClockTest1.java---------------------
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class ClockTest1 extends JFrame{
/**
* @param args
*/
private Clock clock ;
private Date timeNow;
public ClockTest1(){
super("时钟");
setSize(400,400);
setVisible(true);
}
public void paint(Graphics g){
super.paint(g);
timeNow = new Date();
clock = new Clock(timeNow.getHours(),timeNow.getMinutes(),timeNow.getSeconds());
clock.show(g,170,150,100);
try{
//for(int i =0 ; i <10 ; i += 10)
Thread.sleep(1000);
}catch(InterruptedException e){
}
repaint();
}
public static void main(String[] args) {
// TODO 自动生成方法存根
ClockTest1 appication = new ClockTest1();
appication.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
-----------------------------Clock.java-----------
import java.awt.*;
public class Clock {
private int hour;
private int minute;
private int second;
public Clock(){
}
public Clock(int hrs,int min,int sec){
hour =hrs % 12;
minute = min;
second = sec;
}
void show (Graphics g,int cx,int cy,int rad){
int hourLenght = (int)(rad * 0.5);//时针的长度
int minuteLenght = (int)(rad * 0.6);//分针的长度
int secondLenght = (int)(rad * 0.9);//秒针的长度
double angle;//角度
//画出钟面
g.drawOval(cx-rad, cy - rad, rad * 2, rad * 2);
//画出时针
angle = (double)(hour*60*60 + minute*60 + second)/43200.0*2.0*Math.PI;
drawNiddle(g,Color.blue, cx, cy, hourLenght,angle);
//画分针
angle = (double)(minute*60 + second)/3600 * 2.0 * Math.PI;
drawNiddle(g,Color.blue, cx, cy, minuteLenght,angle);
// 画秒针
angle = (double)(second)/60*2.0*Math.PI;
drawNiddle(g,Color.blue, cx, cy, secondLenght,angle);
}
private void drawNiddle(Graphics g ,Color c,int x,int y,int len,double angle){
int ex = (int)(x + len * Math.sin(angle));
int ey = (int)(y - len * Math.cos(angle));
g.setColor(c);
g.drawLine(x,y,ex,ey);
}
}
----------------ClockTest1.java---------------------
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class ClockTest1 extends JFrame{
/**
* @param args
*/
private Clock clock ;
private Date timeNow;
public ClockTest1(){
super("时钟");
setSize(400,400);
setVisible(true);
}
public void paint(Graphics g){
super.paint(g);
timeNow = new Date();
clock = new Clock(timeNow.getHours(),timeNow.getMinutes(),timeNow.getSeconds());
clock.show(g,170,150,100);
try{
//for(int i =0 ; i <10 ; i += 10)
Thread.sleep(1000);
}catch(InterruptedException e){
}
repaint();
}
public static void main(String[] args) {
// TODO 自动生成方法存根
ClockTest1 appication = new ClockTest1();
appication.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
参考下这里的时钟吧,这是一个能在JFrame上显示当前时间的表,并且能随着时间的流动,一秒一秒的移动秒针.如果你想更美观一点还可以在表的中间加一些时间数字.希望能对你有帮助.
-----------------------------Clock.java-----------
import java.awt.*;
public class Clock {
private int hour;
private int minute;
private int second;
public Clock(){
}
public Clock(int hrs,int min,int sec){
hour =hrs % 12;
minute = min;
second = sec;
}
void show (Graphics g,int cx,int cy,int rad){
int hourLenght = (int)(rad * 0.5);//时针的长度
int minuteLenght = (int)(rad * 0.6);//分针的长度
int secondLenght = (int)(rad * 0.9);//秒针的长度
double angle;//角度
//画出钟面
g.drawOval(cx-rad, cy - rad, rad * 2, rad * 2);
//画出时针
angle = (double)(hour*60*60 + minute*60 + second)/43200.0*2.0*Math.PI;
drawNiddle(g,Color.blue, cx, cy, hourLenght,angle);
//画分针
angle = (double)(minute*60 + second)/3600 * 2.0 * Math.PI;
drawNiddle(g,Color.blue, cx, cy, minuteLenght,angle);
// 画秒针
angle = (double)(second)/60*2.0*Math.PI;
drawNiddle(g,Color.blue, cx, cy, secondLenght,angle);
}
private void drawNiddle(Graphics g ,Color c,int x,int y,int len,double angle){
int ex = (int)(x + len * Math.sin(angle));
int ey = (int)(y - len * Math.cos(angle));
g.setColor(c);
g.drawLine(x,y,ex,ey);
}
}
----------------ClockTest1.java---------------------
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class ClockTest1 extends JFrame{
/**
* @param args
*/
private Clock clock ;
private Date timeNow;
public ClockTest1(){
super("时钟");
setSize(400,400);
setVisible(true);
}
public void paint(Graphics g){
super.paint(g);
timeNow = new Date();
clock = new Clock(timeNow.getHours(),timeNow.getMinutes(),timeNow.getSeconds());
clock.show(g,170,150,100);
try{
//for(int i =0 ; i <10 ; i += 10)
Thread.sleep(1000);
}catch(InterruptedException e){
}
repaint();
}
public static void main(String[] args) {
// TODO 自动生成方法存根
ClockTest1 appication = new ClockTest1();
appication.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
-----------------------------Clock.java-----------
import java.awt.*;
public class Clock {
private int hour;
private int minute;
private int second;
public Clock(){
}
public Clock(int hrs,int min,int sec){
hour =hrs % 12;
minute = min;
second = sec;
}
void show (Graphics g,int cx,int cy,int rad){
int hourLenght = (int)(rad * 0.5);//时针的长度
int minuteLenght = (int)(rad * 0.6);//分针的长度
int secondLenght = (int)(rad * 0.9);//秒针的长度
double angle;//角度
//画出钟面
g.drawOval(cx-rad, cy - rad, rad * 2, rad * 2);
//画出时针
angle = (double)(hour*60*60 + minute*60 + second)/43200.0*2.0*Math.PI;
drawNiddle(g,Color.blue, cx, cy, hourLenght,angle);
//画分针
angle = (double)(minute*60 + second)/3600 * 2.0 * Math.PI;
drawNiddle(g,Color.blue, cx, cy, minuteLenght,angle);
// 画秒针
angle = (double)(second)/60*2.0*Math.PI;
drawNiddle(g,Color.blue, cx, cy, secondLenght,angle);
}
private void drawNiddle(Graphics g ,Color c,int x,int y,int len,double angle){
int ex = (int)(x + len * Math.sin(angle));
int ey = (int)(y - len * Math.cos(angle));
g.setColor(c);
g.drawLine(x,y,ex,ey);
}
}
----------------ClockTest1.java---------------------
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class ClockTest1 extends JFrame{
/**
* @param args
*/
private Clock clock ;
private Date timeNow;
public ClockTest1(){
super("时钟");
setSize(400,400);
setVisible(true);
}
public void paint(Graphics g){
super.paint(g);
timeNow = new Date();
clock = new Clock(timeNow.getHours(),timeNow.getMinutes(),timeNow.getSeconds());
clock.show(g,170,150,100);
try{
//for(int i =0 ; i <10 ; i += 10)
Thread.sleep(1000);
}catch(InterruptedException e){
}
repaint();
}
public static void main(String[] args) {
// TODO 自动生成方法存根
ClockTest1 appication = new ClockTest1();
appication.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
如果记录非常精确的话,可以用TickCount,记录点击时代开机时间,连续记录两次,之间的差值就是很精确的时间,其他的Java控件应该有吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你只需要分别找显示时间,修改时间,还有闹铃功能,然后自己合而为一就可以了啦...
靠自己快过靠别人。。。
靠自己快过靠别人。。。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
自己查一下API摸索着做吧!编程这种事别人能替你一时却替不了你一世
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询