/** Constructor for PCF8563Demo. */
  public PCF8563Demo() {

    my8563 = new PCF8563();
    ttrans = new Time();
    Display lcd = new Display();

    // initialize the rtc
    try {
      my8563.reset();
    } catch (IOException ex) {
    }

    // get time/date from rtc
    try {
      my8563.getTime(ttrans);
    } catch (IOException ex) {
      if (ex instanceof TimeIntegrityLostException) {
        lcd.drawString("PCF8563-time not valid", 4, 31);
      }
    }

    // set time/date of the JCU
    RTC.setTime(ttrans);

    // initialize vole components
    mainContainer = new Container();
    mainContainer.setBounds(0, 0, 128, 64);
    this.add(mainContainer);
    mainMenu();
    setVisible(true);
  }
  /**
   * Overwritten ActionEvent event handler.
   *
   * @param e the ActionEvent
   * @see jcontrol.ui.vole.Component.onActionEvent(ActionEvent e)
   */
  public void onActionEvent(ActionEvent e) {
    if (e.getType() == ActionEvent.BUTTON_PRESSED) {
      // check which button was pressed
      if (e.getSource() == changeButton) {
        modifyMenu(); // open the time modify page
      } else if (e.getSource() == okButton) {
        // confirm time settings changes
        try {
          my8563.setTime(
              new Time(
                  yearChange.getValue(),
                  monthChange.getValue(),
                  dayChange.getValue(),
                  0,
                  hourChange.getValue(),
                  minuteChange.getValue(),
                  secondChange.getValue()));
        } catch (IOException ex) {
        }

        // update time/date of JCU
        try {
          my8563.getTime(ttrans);
        } catch (IOException ex) {
        }
        RTC.setTime(ttrans);

        // go back to main menu
        mainMenu();

      } else if (e.getSource() == cancelButton) {

        // go back to main menu without changes
        mainMenu();
      }
    }
  }