med = new Mediator(); MementoDemo() { JPanel p = new JPanel(); p.add(new BtnDice(this,med)); p.add(new BtnPrevious(this,med)); p.add(new BtnClear(this,med)); JPanel dice = new JPanel(); LblDisplay lbl = new LblDisplay(med); dice.add(lbl); getContentPane().add(dice, "Center"); getContentPane().add(p, "South"); setTitle("Memento pattern example"); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(400,200); setVisible(true); } public void actionPerformed(ActionEvent ae) { Command comd = (Command)ae.getSource(); comd.execute(); } Samstag, 24. November 12