展开全部
package test;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.*;
import java.util.Date;
import java.text.SimpleDateFormat;
/**
* <p>File: StopWatch.java</p>
* <p>Description: </p>
* <p><a href="http://www.bioz.info/">BIOZ.info</a> Copyright (c) 2004</p>
*
* @author <a href="mailto:chancewang78@hotmail.com">Chance</a>
*/
public class StopWatch extends JFrame {
JButton btnStart,btnStop;
JLabel label;
Timer timer;
public StopWatch() {
label=new JLabel("00:00:00.000");
btnStart=new JButton("start");
btnStop=new JButton("stop");
final int delay=100;
final Date startTime=new Date();
final SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss.S");
final Action taskPerformer = new AbstractAction() {
public void actionPerformed(ActionEvent evt) {
//显示时间
Date d=new Date(System.currentTimeMillis()-startTime.getTime()-28800000);
label.setText(sdf.format(d));
label.repaint();
}
};
btnStart.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
startTime.setTime(new Date().getTime());
timer=new Timer(delay, taskPerformer);
timer.start();
}
});
btnStop.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
if(timer!=null&&timer.isRunning())
timer.stop();
}
});
Container c=getContentPane();
c.add(label,BorderLayout.NORTH);
c.add(btnStart,BorderLayout.CENTER);
c.add(btnStop,BorderLayout.SOUTH);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
private static void createAndShowGUI() {
StopWatch window=new StopWatch();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.pack();
window.setVisible(true);
}
}
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.*;
import java.util.Date;
import java.text.SimpleDateFormat;
/**
* <p>File: StopWatch.java</p>
* <p>Description: </p>
* <p><a href="http://www.bioz.info/">BIOZ.info</a> Copyright (c) 2004</p>
*
* @author <a href="mailto:chancewang78@hotmail.com">Chance</a>
*/
public class StopWatch extends JFrame {
JButton btnStart,btnStop;
JLabel label;
Timer timer;
public StopWatch() {
label=new JLabel("00:00:00.000");
btnStart=new JButton("start");
btnStop=new JButton("stop");
final int delay=100;
final Date startTime=new Date();
final SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss.S");
final Action taskPerformer = new AbstractAction() {
public void actionPerformed(ActionEvent evt) {
//显示时间
Date d=new Date(System.currentTimeMillis()-startTime.getTime()-28800000);
label.setText(sdf.format(d));
label.repaint();
}
};
btnStart.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
startTime.setTime(new Date().getTime());
timer=new Timer(delay, taskPerformer);
timer.start();
}
});
btnStop.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
if(timer!=null&&timer.isRunning())
timer.stop();
}
});
Container c=getContentPane();
c.add(label,BorderLayout.NORTH);
c.add(btnStart,BorderLayout.CENTER);
c.add(btnStop,BorderLayout.SOUTH);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
private static void createAndShowGUI() {
StopWatch window=new StopWatch();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.pack();
window.setVisible(true);
}
}
展开全部
<html>
<head>
<script language="javascript">
var hour=45
var minute=0
var second=0
function clockShow(){
second=second-1;
if (second<0)
{
second=59;
minute=minute-1;
}
if (minute<0)
{
minute=59;
hour=hour-1;
}
if (second==1)
{
document.form1.submit()
}
document.myform.myclock.value=hour+":"+minute+":"+second;
var myTime = setTimeout("clockShow()",1000);
}
</script>
</head>
<body onLoad="clockShow()">
<form NAME="myform">
<INPUT type="text" name="myclock" >
</form>
<p> </p>
<form name="form1" method="post" action="http://www.baidu.com">
<input type="text" name="textfield">
<input type="submit" name="Submit" value="提交">
</form>
<p> </p>
</body>
</html>
<head>
<script language="javascript">
var hour=45
var minute=0
var second=0
function clockShow(){
second=second-1;
if (second<0)
{
second=59;
minute=minute-1;
}
if (minute<0)
{
minute=59;
hour=hour-1;
}
if (second==1)
{
document.form1.submit()
}
document.myform.myclock.value=hour+":"+minute+":"+second;
var myTime = setTimeout("clockShow()",1000);
}
</script>
</head>
<body onLoad="clockShow()">
<form NAME="myform">
<INPUT type="text" name="myclock" >
</form>
<p> </p>
<form name="form1" method="post" action="http://www.baidu.com">
<input type="text" name="textfield">
<input type="submit" name="Submit" value="提交">
</form>
<p> </p>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询