/Users/lyon/j4p/src/ip/gui/frames/FileMenuFrame.java

1    package ip.gui.frames; 
2     
3    import java.awt.*; 
4    import java.awt.event.ActionEvent; 
5    import java.awt.event.ActionListener; 
6     
7    public class FileMenuFrame extends ImageFrame implements ActionListener { 
8        MenuBar mb = new MenuBar(); 
9        Menu FileMenu = getMenu("File"); 
10       MenuItem print_mi = addMenuItem(FileMenu, "[E-p]rint"); 
11    
12       FileMenuFrame(String title) { 
13           super(title); 
14           mb.add(FileMenu); 
15           setMenuBar(mb); 
16       } 
17    
18       public void actionPerformed(ActionEvent e) { 
19           if (match(e, print_mi)) { 
20               print(this); 
21               return; 
22           } 
23           super.actionPerformed(e); 
24    
25       } 
26    
27       public static void print(Frame f) { 
28           Toolkit tk = Toolkit.getDefaultToolkit(); 
29           PrintJob printJob = 
30                   tk.getPrintJob( 
31                           f, 
32                           "print me!", 
33                           null); 
34           Graphics g = printJob.getGraphics(); 
35           f.paint(g); 
36           printJob.end(); 
37       } 
38    
39   }