March 2002
Intermediate to advanced
496 pages
8h 51m
English
| SOLUTION 24.1 | Java Swing applications commonly apply the MEDIATOR pattern, registering a single object to receive all GUI events. This object mediates the interaction of the components and translates user input into commands for business domain objects. |
| SOLUTION 24.2 | Your code should look something like:
protected JMenu fileMenu() { if (fileMenu == null) { fileMenu = new JMenu("File"); Font f = SwingFacade.getStandardFont(); fileMenu.setFont(f); JMenuItem save = new JMenuItem("Save"); save.setFont(f); fileMenu.add(save); save.addActionListener ( new ActionListener() { public void actionPerformed(ActionEvent e) { save(); } } ); JMenuItem load = new JMenuItem("Load"); load.setFont(f); fileMenu.add(load); load.addActionListener ... |
Read now
Unlock full access