import java.awt.*; class ControlPanel extends Panel { private SetDaysFrame setDaysFrame; private BiorhythmCanvas biorhythmCanvas; private Biorhythm yourBiorhythm; private CalcDate calculator; private Button nextButton, prevButton, setButton; public ControlPanel(SetDaysFrame setDaysFrame, BiorhythmCanvas biorhythmCanvas, Biorhythm yourBiorhythm) { this.setDaysFrame = setDaysFrame; this.biorhythmCanvas = biorhythmCanvas; this.yourBiorhythm = yourBiorhythm; calculator = new CalcDate(); setBackground(Color.gray); nextButton = new Button("Next"); prevButton = new Button("Prev"); setButton = new Button("Set Days"); add(prevButton); add(nextButton); add(setButton); } public boolean action(Event e, Object o) { if (e.target == nextButton) { calculator.set(yourBiorhythm.getCalcYear(), yourBiorhythm.getCalcMonth(), yourBiorhythm.getCalcDate()); long pastDays = calculator.getPastDays(); calculator.setPastDays(pastDays + 1); yourBiorhythm.setCalculateDay(calculator.getYear(), calculator.getMonth(), calculator.getDate()); biorhythmCanvas.repaint(); return true; } else if (e.target == prevButton) { calculator.set(yourBiorhythm.getCalcYear(), yourBiorhythm.getCalcMonth(), yourBiorhythm.getCalcDate()); long pastDays = calculator.getPastDays(); calculator.setPastDays(pastDays - 1); yourBiorhythm.setCalculateDay(calculator.getYear(), calculator.getMonth(), calculator.getDate()); biorhythmCanvas.repaint(); return true; } else if (e.target == setButton) { setDaysFrame.show(); setDaysFrame.repaint(); return true; } return false; } public void setBackgroundColor(Color backgroundColor) { setBackground(backgroundColor); } private void mb(int x, int y, Button button, GridBagLayout gb, GridBagConstraints gc, Panel p) { gc.gridx = x; gc.gridy = y; gb.setConstraints(button, gc); p.add(button); } }