LEDClock Bean


Table of Contents

 


 

Introduction

Purpose

The LEDClock component is a Java bean that can be used to display a digital clock in various applications and applets. The developer can completely customize the look and feel of the clock.The developer can set an alarm and time zone adjustment. The clock digit's are resizable .

Audience

This document describes the LEDClock bean. It is intended for "application assembler" who will be able to use the component in a visual builder as well as for manual programming. It is assumed that the users are already familiar with JavaBeans. If terms like property, event, method, introspection, or serialization is unfamiliar, they may want to refer to the JavaBeans documentation or take the JavaBeans tutorial.

Copyrights and Trademarks

© International Business Machines Corporation 1998. All rights reserved.


 

Class Description

Class Name: LEDClock

Implements: Serializable

Overview:

This is a visual bean.
The LEDClock component is a Java bean that can be used to display a digital clock in various applications and applets. The developer can completely customize the look and feel of the clock. The developer can set an alarm and time zone adjustment. The clock digits are resizable.

LEDClock d = new LEDClock();
add(d);

Introspection:

A SimpleBeanInfo class, LEDClockBeanInfo, explicitly provides information for properties, events, and methods.

Wiring:

- Install LEDClock in the IDE palette.
- Choose the component from the palette and drop it onto the visual portion of your free-form surface.
- Customize the  timeadjustment , mode24hours , showSeconds properties with the help of the Property sheet.
- If you want to use alarm you should set the alarmSet property to true and customize alarmtime.  The setting of these properties will start alarm.
- Wire the AlarmEvent event to the method/methods of other beans which should be invoked when the time comes.


 Properties

Property Summary

 

boolean showSeconds

[bound]

show / hide seconds flag

(r/w)

boolean mode24hours

[bound]

show hour value more than 12 or not 

(r/w)

boolean alarmSet

[bound]

alarm on /off flag

(r/w)

int seconds

[bound , hidden]

displayed seconds

(r/w)

int minutes

[bound, hidden]

displayed minutes

(r/w)

int hours

[bound, hidden]

displayed hours

(r/w)

int timeadjustment

[bound]

system time adjustment in seconds 

(r/w)

int alarmtime

[bound]

alarm signal time

(r/w)

 


Properties

showSeconds [bound] - show / hide seconds flag

Type: boolean


Get: isShowSeconds()
Set: setShowSeconds( boolean )

 

mode24hours [bound] - show hour value more than 12 or not

Type: boolean


Get: isMode24hours()
Set: setMode24hours( boolean )
 

 alarmSet [bound] - alarm on/off flag

Type: boolean


Get: isAlarmSet()
Set: setAlarmSet( boolean )
 

seconds [bound , hidden] - displayed seconds

Type: int

Get: getSeconds()
Set: setSeconds( int )  

minutes [bound , hidden] - displayed minutes


Type: int

Get: getMinutes()
Set: setMinutes( int )  

hours [bound , hidden] - displayed hours

Type: int

Get: getHours()
Set: setHours( int )  

 timeadjustment [bound] - system time adjustment in seconds

Type: int


Get: getTimeadjustment()
Set: setTimeadjustment( int )
 

 alarmtime [bound] - alarm signal time

Type: int
Get: getAlarmtime()
Set: setAlarmtime( int )
 


 Methods

Method Summary
 

instantiation LEDClock() 
accessing properties  isShowSeconds() 
 setShowSeconds( boolean ) 
 isMode24hours() 
 setMode24hours( boolean ) 
 isAlarmSet() 
 setAlarmSet( boolean ) 
 getSeconds() 
 setSeconds( int ) 
 getMinutes() 
 setMinutes( int ) 
 getHours() 
 setHours( int ) 
 getTimeadjustment() 
 setTimeadjustment( int ) 
 getAlarmtime() 
 setAlarmtime( int ) 
paint/update/getPreferredSize methods paint( Graphics ) 
update( Graphics )  
getPreferredSize( )
adding/removing listeners addAlarmEventListener( AlarmEventListener ) 
removeAlarmEventListener( AlarmEventListener )  
addPropertyChangeListener(PropertyChangeListener)  
removePropertyChangeListener(PropertyChangeListener) 

 


Methods

LEDClock

public LEDClock()

Constructor by default. Creates a LEDClock synchronized with system clock for GMT 0 time zone.

 

paint

public void paint(Graphics gr)

Paints the component.

Parameters:

gr - java.awt.Graphics

Overrides:

paint in class Component

 

update

public void update(Graphics gr)

Updates the component.

Parameters:

gr - java.awt.Graphics

Overrides:

update in class Component

 

getPreferredSize

public Dimension getPreferredSize()

Returns component preferred size.

Parameters:

Overrides:

getPreferredSize in class Component

 

addAlarmEventListener

public void addAlarmEventListener(AlarmEventListener l)

Adds a specified alarm listener to receive alarm events from this LEDClock.

Parameters:

l - an alarm listener

 

removeAlarmEventListener

public void removeAlarmEventListener(AlarmEventListener l)

Removes a specified alarm listener, so it no longer receives alarm events from this LEDClock.

Parameters:

l - an alarm listener

 

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

Registers a new listener of the PropertyChange event.

Parameters:

l - reference to an object to be registered as a listener of the PropertyChange event

 

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

Removes a listener of the PropertyChange event.

Parameters:

l - reference to an object to be removed as a listener of the PropertyChange event

 

isShowSeconds

public boolean isShowSeconds()

Returns a show seconds flag

Returns :

    Show seconds flag

 

setShowSeconds

public void setShowSeconds( boolean b )

Sets new value of a show seconds flag

Parameters :

      b - new value of a show seconds flag

 

isMode24hours

public boolean isMode24hours()

Returns a mode 24 hours flag

Returns :

    mode 24 hours flag

 

setMode24hours

public void setMode24hours( boolean b )

Sets new value of a mode 24 hours flag

Parameters :

      b - new value of a mode 24 hours flag

 

isAlarmSet

public boolean isAlarmSet()

Returns a alarm set  flag

Returns :

    alarm set  flag

 

setAlarmSet

public void setAlarmSet( boolean b )

Sets new value of a alarm set  flag

Parameters :

      b - new value of a alarm set  flag

getSeconds

public int getSeconds()

Returns displayed seconds

Returns :

    displayed seconds

 

setSeconds

public void setSeconds( int i )

Sets new value of displayed seconds

Parameters :

      i - new value of displayed seconds

 

getMinutes

public int getMinutes()

Returns displayed minutes

Returns :

    displayed minutes

 

setMinutes

public void setMinutes( int i )

Sets new value of displayed minutes

Parameters :

      i - new value of displayed minutes

 

getHours

public int getHours()

Returns displayed hours

Returns :

    displayed hours

 

setHours

public void setHours( int i )

Sets new value of displayed hours

Parameters :

      i - new value of displayed hours

 

getTimeadjustment

public int getTimeadjustment()

Returns time adjustment by system clock ( in seconds )

Returns :

    time adjustment by system clock ( in seconds )

 

setTimeadjustment

public void setTimeadjustment( int i )

Sets new value of time adjustment by system clock ( in seconds )

Parameters :

      i - new value of time adjustment by system clock ( in seconds )

 

getAlarmtime

public int getAlarmtime()

Returns alarm signal time ( in seconds )

Returns :

    alarm signal time ( in seconds )

 

setAlarmtime

public void setAlarmtime( int i )

Sets new value of alarm signal time ( in seconds )

Parameters :

      i - new value of alarm signal time ( in seconds )


 Events

Events Summary

As Source
EventListener Interfaces: PropertyChangeListener 
AlarmEventListener
Event Objects: PropertyChangeEvent 
AlarmEvent
As Listener
does not act as a listener

Events

 

The LEDClock bean fires an event that is a post-notification of a property change (bound). Listeners register for the post-notification of bound properties with addPropertyChangeListener().

The LEDClock bean fires an AlarmEvent if the displayed time is equal to alarm time and alarm is on. Listeners register for the post-notification of alarm with addAlarmEventListener().
 


 

Component Reference Pages

Click here to see the related documentation.