com.palserv.clock
Class BinaryClock

java.lang.Object
  extended by com.palserv.clock.BinaryClock

public class BinaryClock
extends java.lang.Object

Make a binary clock. I have seen a physical version with LEDs and I loved it. So I made one in Java. It displays the time in six columns of four rows each. Each column represents a decimal digit, 0-9. Thus this display:

 +---+---+---+---+---+---+
 |   |   |   | X |   |   |
 +---+---+---+---+---+---+
 |   | X |   |   |   | X |
 +---+---+---+---+---+---+
 |   |   |   |   | X | X |
 +---+---+---+---+---+---+
 |   | X | X | X | X | X |
 +---+---+---+---+---+---+
 
represents 06:19:37, or 6:19 and 37 seconds.


Constructor Summary
BinaryClock()
           
 
Method Summary
 void getArgs(java.lang.String[] args)
          Get the command line arguments.
static void main(java.lang.String[] args)
          Run the clock from the command line.
 javax.swing.JPanel makeContentPane()
          Create the clock in a JPanel.
 void makeFrame()
          Create a frame so the GUI can run in a separate window.
 void runClock()
          Run the clock.
 void setClock(int hour, int minute, int second)
          Set the time to the given BTime object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryClock

public BinaryClock()
Method Detail

main

public static void main(java.lang.String[] args)
Run the clock from the command line. All arguments are quietly ignored. Internally, this implementation looks like this:
           BinaryClock bc = new BinaryClock();
           bc.makeFrame();
           bc.runClock();
 
This code could be used from another program.

Parameters:
args - ignored

getArgs

public void getArgs(java.lang.String[] args)
Get the command line arguments.

Parameters:
args - the arguments as passed to main

runClock

public void runClock()
Run the clock. Requires certain initialization, in particular, makeContentPane should be invoked before this method.


makeFrame

public void makeFrame()
Create a frame so the GUI can run in a separate window. Sets the content pane of the JFrame to the return from makeContentPane.


makeContentPane

public javax.swing.JPanel makeContentPane()
Create the clock in a JPanel.

Returns:
the clock.

setClock

public void setClock(int hour,
                     int minute,
                     int second)
Set the time to the given BTime object.

Parameters:
hour - the current hour
minute - the current minute
second - the current second