public class InsertTime
extends java.lang.Object
implements java.lang.Runnable
Title: Insert time
Description: Places the count of elapsed seconds into a JLabel
Copyright: Copyright (c) 2004, David Read
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Modifier and Type | Field and Description |
---|---|
private long |
epoch
The starting time offset (e.g.
|
private javax.swing.JLabel |
label
The component backing this instance
|
private static org.apache.log4j.Logger |
LOGGER
Logger
|
private static int |
MILLISECONDS_PER_SECOND
Number of miiliseconds per second
|
private static int |
MINUTES_PER_HOUR
Number of minutes per hour
|
private int |
msDelay
Time to delay between updates of the label
|
private static java.text.NumberFormat |
NUMBER_FORMAT
Format for the label to display its value
|
private static int |
SECONDS_PER_MINUTE
Number of seconds per minute
|
Constructor and Description |
---|
InsertTime(javax.swing.JLabel aComp,
long aMSZeroTime,
int aMSDelay)
Create a new InsertTime instance associated with a JLabel.
|
Modifier and Type | Method and Description |
---|---|
private int |
hours(long ms)
Calculate the number of hours represented by the number of milliseconds
provided.
|
private int |
minutes(long ms)
Calculate the number of minutes represented by the number of milliseconds
provided.
|
void |
run()
Track the elapsed seconds, updating the JLabel until an interrupt
is received.
|
private int |
seconds(long ms)
Calculate the number of seconds represented by the number of milliseconds
provided.
|
private static final org.apache.log4j.Logger LOGGER
private static final int MILLISECONDS_PER_SECOND
private static final int SECONDS_PER_MINUTE
private static final int MINUTES_PER_HOUR
private javax.swing.JLabel label
private long epoch
private int msDelay
private static final java.text.NumberFormat NUMBER_FORMAT
public InsertTime(javax.swing.JLabel aComp, long aMSZeroTime, int aMSDelay)
aComp
- The JLabel that this instance will updateaMSZeroTime
- The time considered as the start time.aMSDelay
- The number of milliseconds between updates of the time value.private int hours(long ms)
ms
- Millisecondsprivate int minutes(long ms)
ms
- Millisecondsprivate int seconds(long ms)
ms
- Millisecondspublic void run()
run
in interface java.lang.Runnable