import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;
public class TimeViewer extends Applet implements ActionListener,Runnable
{
//所需要的数据定义
Thread timer;
TextField in,out;
Button bb;
Panel p1,p2,p3;
boolean state;
public void init ()
{
in = new TextField (20);
out = new TextField (20);
bb = new Button ("Current Time:");//设置出按钮
p1 = new Panel();
p2 = new Panel();
p3 = new Panel();
setLayout(new GridLayout(3,1));
setSize(200,100);
p1.add(in);
p2.add(bb);
p3.add(out);
add(p1);
add(p2);
add(p3);
bb.addActionListener(this);
timer = new Thread(this);
state = true;
timer.start();
}
public void actionPerformed (ActionEvent e)
{
//out.setText(in.getText());
out.setText(currentTime());
}
public void run()
{
while (true)
{
try
{
timer.sleep(1000);
}
catch(InterruptedException e){}
in.setText(currentTime());;
}
}
String currentTime()
{
Date now = new Date();
String str = now.getHours() + ":" +now.getMinutes() + ":" +now.getSeconds();
return str;
}
}
求解释一个JAVA(秒表)的小程序,可以给代码标记注释的。新手,看不懂代码...
\/\/定义两个文本框Button bb;\/\/定义一个按钮,用于开始\/停止Panel p1,p2,p3;\/\/三个panel,摆放组件boolean state;\/\/当前状态的布尔值 public void init () { in = new TextField (20); out = new TextField (20); \/\/--以上初始化文字框,长度为20 bb = new Button ("...
java秒表小程序编写
收藏的一个小程序。import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.text.DecimalFormat;import java.text.NumberFormat;import javax.swing.JApplet;import javax.swing.JButton;import javax.swing.JLabel;public class TimerApplet extends J...
能否帮忙编写一个秒表计时器,把记录的数值导入到excel中
Private Sub Timer1_Timer()ex1.Visible = True '以上代码是运行excel并新建一个文档 ex1.Range("a" & ii).Value = Text1.Text '把textbox中的数据逐条记录到EXCEL中的A列,一条记录一行 ii = Val(ii) + 1 '每记录一条记录,excel行数+1 End Sub ...