2个回答
展开全部
点开始计时就从0开始,并在文本框中显示.点停止计时就停止.
你说的面板上是什么面板!!代码发来看看!!!!是用什么做的!!!VS吗??
<html>
<head>
<script type="text/javascript">
var c=0
var t
function timedCount()
{
document.getElementById('txt').value=c
c=c+1
t=setTimeout("timedCount()",1000)
}
function stopCount()
{
clearTimeout(t)
}
</script>
</head>
<body>
<form>
<input type="button" value="开始计时!" onClick="timedCount()">
<input type="text" id="txt">
<input type="button" value="停止计时!" onClick="stopCount()">
</form>
<p>请点击上面的“开始计时”按钮来启动计时器。输入框会一直进行计时,从 0 开始。点击“停止计时”按钮可以终止计时。</p>
</body>
</html>
你说的面板上是什么面板!!代码发来看看!!!!是用什么做的!!!VS吗??
<html>
<head>
<script type="text/javascript">
var c=0
var t
function timedCount()
{
document.getElementById('txt').value=c
c=c+1
t=setTimeout("timedCount()",1000)
}
function stopCount()
{
clearTimeout(t)
}
</script>
</head>
<body>
<form>
<input type="button" value="开始计时!" onClick="timedCount()">
<input type="text" id="txt">
<input type="button" value="停止计时!" onClick="stopCount()">
</form>
<p>请点击上面的“开始计时”按钮来启动计时器。输入框会一直进行计时,从 0 开始。点击“停止计时”按钮可以终止计时。</p>
</body>
</html>
展开全部
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Go extends Thread,JFrame,Runable{
public void run(){
for(;;sec++){
if(sec==60){sec++;sec=0;}
if(sec==60){minute++;sec=0;}
if(minute==60){hour++;minute=0;}
try
{
Thread.sleep(1);
}
catch(Exception f){}
TF.setText(""+hour+":"+minute+":"+sec);
}
}
}
public class a implements ActionListener{
static int hour,minute=0,sec=0;
JButton BT1;
static int temp=0;
JTextField TF;
public static void main(String []args){
a b=new a();
b.go();
}
public void go(){
JFrame frame=new JFrame("计时器");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(100,100);
frame.setVisible(true);
TF=new JTextField("00:00:00");BT1=new JButton("开始");BT1.addActionListener(this);
JPanel Jp=new JPanel();Jp.add(BT1);Jp.add(TF);
Container container=frame.getContentPane();container.add(Jp);
}
public void actionPerformed(ActionEvent e){
JButton bt16=(JButton)e.getSource();
if(bt16==BT1) go1();
}
public void go1(){for(;;sec++){
if(sec==60){sec++;sec=0;}
if(sec==60){minute++;sec=0;}
if(minute==60){hour++;minute=0;}
try
{
Thread.sleep(1);
}
catch(Exception f){}
TF.setText(""+hour+":"+minute+":"+sec);
}
}
}
import java.awt.*;
import java.awt.event.*;
class Go extends Thread,JFrame,Runable{
public void run(){
for(;;sec++){
if(sec==60){sec++;sec=0;}
if(sec==60){minute++;sec=0;}
if(minute==60){hour++;minute=0;}
try
{
Thread.sleep(1);
}
catch(Exception f){}
TF.setText(""+hour+":"+minute+":"+sec);
}
}
}
public class a implements ActionListener{
static int hour,minute=0,sec=0;
JButton BT1;
static int temp=0;
JTextField TF;
public static void main(String []args){
a b=new a();
b.go();
}
public void go(){
JFrame frame=new JFrame("计时器");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(100,100);
frame.setVisible(true);
TF=new JTextField("00:00:00");BT1=new JButton("开始");BT1.addActionListener(this);
JPanel Jp=new JPanel();Jp.add(BT1);Jp.add(TF);
Container container=frame.getContentPane();container.add(Jp);
}
public void actionPerformed(ActionEvent e){
JButton bt16=(JButton)e.getSource();
if(bt16==BT1) go1();
}
public void go1(){for(;;sec++){
if(sec==60){sec++;sec=0;}
if(sec==60){minute++;sec=0;}
if(minute==60){hour++;minute=0;}
try
{
Thread.sleep(1);
}
catch(Exception f){}
TF.setText(""+hour+":"+minute+":"+sec);
}
}
}
追问
你这个运行不了啊 找不到符号的 for(;;sec++){
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询