JAVA计时器(秒表)程序代码.docVIP

  • 87
  • 0
  • 约2.81千字
  • 约 7页
  • 2022-01-17 发布于广东
  • 举报
Java计时器(秒表) 功能:能实现计时,暂停,清零,记录功能。如下图:程序运行状态: □ □ X Q : 0 : 开曲 清霎 记录 滴空记录 源代码: import javax.swing.*; import java.awt.*; import java.awt.event.*; publicclass Test { args ){publicstaticvoid mai n( Stri ng[] args ){ newwindow(计时器”); class window extends JFrame{ int ON=0, i =0, j =0, k=0, count =0, num=1, R=0; ,button5JTextField file1,file2 , file3JButton button1 , button2 , button3 , button4 ,button5 JTextField file1 ,file2 , file3 JTextArea file ; FlowLayout flow ; String a, b, c; win dow(Stri ng n ame) { file1=n ewJTextField(2);file2=n ewJTextField(2); file1 =n ewJTextField(2); file2 =n ewJTextField(2); file1 .setEditable( false file2 .setEditable( false file3 .setEditable( false file =n ewJTextArea(10,8); file .setEditable( false file3 =n ewJTextField(2); ); ); ); ); butt on1 =n ewJButt on(开始”); butt on2 =n ewJButt on(暂停”); butto n3 =n ewJButt on(清零”); butt on4 =n ewJButt on(记录”); button5 =newJButton( 清空记录 ); flow =newFlowLayout(); flow .setAlignment(FlowLayout. LEFT); flow .setHgap(20); flow .setVgap(10); setTitle( name); setSize(210,400); setLayout( flow ); add( file1 ); add( newJLabel( : )); add( file2 ); add( newJLabel( : )); add( file3 ); add( button1 ); add( button2 ); add( button3 ); add( button4 ); add( button5 ); add( file ); setVisible( true ); setDefaultCloseOperation( EXIT_ON_CLOSE); file1 .setText( 0 ); file2 .setText( 0 ); file3 .setText( 0 ); validate(); button1 .addActionListener( newActionListener() { publicvoid actionPerformed(ActionEvent e) { ON=1; // 开始,暂停控制开关 } }); // 开始按钮 button2 .addActionListener( newActionListener() { publicvoid actionPerformed(ActionEvent e){ ON=0; } }); // 暂停按钮 button3 .addActionListener( newActionListener() { publicvoid actionPerformed(ActionEvent e){ R=1; // 清零控制开关 } }); // 清零按钮 button4 .addActionListener( newActionListener() { publicvoid actionPerformed(ActionEvent e) { count =1; // 记录控制开关 { { a=String. valueOf ( i ); b=String. valueOf ( j ); c=String. valueOf ( k); } }); // 记录按钮 button5 .addActionListener( newActionLi

文档评论(0)

1亿VIP精品文档

相关文档