/** * 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(); } } }
/** The time modify page. */ void modifyMenu() { modify = true; // stop the time request thread if (timeRequester != null) { while (!timeRequesterReady) { try { ThreadExt.sleep(100); } catch (InterruptedException ex) { } } timeRequester = null; } mainContainer.removeAll(); // remove all components graphics.clearRect(0, 0, 128, 64); // clear screen day = null; // delete all components for the garbage collector month = null; year = null; clock = null; changeButton = null; mainContainer.add(new Border("Datum/Uhrzeit stellen", 0, 0, 128, 64)); // border okButton = new Button("Ok", 2, 51, 40, 11); // ok button okButton.setActionListener(this); mainContainer.add(okButton); cancelButton = new Button("Abbrechen", 44, 51, 40, 11); // cancel button cancelButton.setActionListener(this); mainContainer.add(cancelButton); // initialize all number choosers with the current time Time t = new Time(); dayChange = new NumberChooser(10, 10, 1, 31); // day dayChange.setValue(t.day); mainContainer.add(dayChange); dayChange.setActionListener(this); monthChange = new NumberChooser(40, 10, 1, 12); // month monthChange.setValue(t.month); mainContainer.add(monthChange); monthChange.setActionListener(this); yearChange = new NumberChooser(70, 10, 2003, 2099); // year yearChange.setValue(t.year); mainContainer.add(yearChange); yearChange.setActionListener(this); hourChange = new NumberChooser(10, 25, 0, 23); // hours hourChange.setValue(t.hour); mainContainer.add(hourChange); hourChange.setActionListener(this); minuteChange = new NumberChooser(40, 25, 0, 59); // minutes minuteChange.setValue(t.minute); mainContainer.add(minuteChange); minuteChange.setActionListener(this); secondChange = new NumberChooser(70, 25, 0, 59); // seconds secondChange.setValue(t.second); mainContainer.add(secondChange); secondChange.setActionListener(this); okButton.requestFocus(); }