filmov
tv
Java stopwatch ⏱️
Показать описание
java stopwatch program
#java #stopwatch #program
// ***************************************************
public class Main {
public static void main(String[] args) {
Stopwatch stopwatch = new Stopwatch();
}
}
// ***************************************************
public class Stopwatch implements ActionListener{
JFrame frame = new JFrame();
JButton startButton = new JButton("START");
JButton resetButton = new JButton("RESET");
JLabel timeLabel = new JLabel();
int elapsedTime = 0;
int seconds =0;
int minutes =0;
int hours =0;
boolean started = false;
Timer timer = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
elapsedTime=elapsedTime+1000;
hours = (elapsedTime/3600000);
minutes = (elapsedTime/60000) % 60;
seconds = (elapsedTime/1000) % 60;
}
});
Stopwatch(){
}
@Override
public void actionPerformed(ActionEvent e) {
if(started==false) {
started=true;
start();
}
else {
started=false;
stop();
}
}
started=false;
reset();
}
}
void start() {
}
void stop() {
}
void reset() {
elapsedTime=0;
seconds =0;
minutes=0;
hours=0;
}
}
#java #stopwatch #program
// ***************************************************
public class Main {
public static void main(String[] args) {
Stopwatch stopwatch = new Stopwatch();
}
}
// ***************************************************
public class Stopwatch implements ActionListener{
JFrame frame = new JFrame();
JButton startButton = new JButton("START");
JButton resetButton = new JButton("RESET");
JLabel timeLabel = new JLabel();
int elapsedTime = 0;
int seconds =0;
int minutes =0;
int hours =0;
boolean started = false;
Timer timer = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
elapsedTime=elapsedTime+1000;
hours = (elapsedTime/3600000);
minutes = (elapsedTime/60000) % 60;
seconds = (elapsedTime/1000) % 60;
}
});
Stopwatch(){
}
@Override
public void actionPerformed(ActionEvent e) {
if(started==false) {
started=true;
start();
}
else {
started=false;
stop();
}
}
started=false;
reset();
}
}
void start() {
}
void stop() {
}
void reset() {
elapsedTime=0;
seconds =0;
minutes=0;
hours=0;
}
}
Комментарии