// select 24-h clock mode
void hr24RadioButton_Action(Event event)
{
  // get value of embedded variable "State"
  Object object = emJri.getJSJriVariable("State"); 
  int state;
  // disable am/pm buttons
  amRadioButton.enable(false); 
  pmRadioButton.enable(false);
  isClock12 = false;
  state = ((Integer)object).intValue();
  /* instead of using a separate variable (wasted resource) to 
     hold clock mode, set bit 0 of the State variable to indicate 
    24-h clock mode. */
  emJri.setJSJriVariable("State", new Integer(state | 0x0001));
  set_hours(); // update clock
}

// change clock to am
void amRadioButton_Action(Event event)
{
/* reset embedded variable "Hrs." Device runs in 24-h mode so 
   subtract 12 from current hour. Since there is a JriLink to 
   this variable, notifyChange will be called and complete the 
   clock update */
  emJri.setJSJriVariable("Hrs", new Integer(hours-12));
}

// set current day
void dayChoice_Action(Event event)
{
  int day = dayChoice.getSelectedIndex();
  /* set current day from 0 to 6 depending on the selected item */
  emJri.setJSJriVariable("Days", new Integer(day));
  dayLabel.setText(dayNames[day]);
}

Listing 2Events are generated every time an action is taken at the interface (e.g., text entered, boxes checked, items selected). This code describes the event-handling functions for the 24-/12-h clock, a.m./p.m. selection, and day selection.