/Users/lyon/j4p/src/bookExamples/ch12Nested/inner/AnonymousInnerClass.java

1    package bookExamples.ch12Nested.inner; 
2     
3    import javax.swing.JPanel; 
4    import java.awt.Graphics; 
5     
6    /** 
7     * DocJava, Inc. 
8     * http://www.docjava.com 
9     * Programmer: dlyon 
10    * Date: Sep 8, 2004 
11    * Time: 7:34:01 PM 
12    */ 
13   class Test { 
14       AnonymousInnerClass aic = new AnonymousInnerClass(); 
15       AnonymousInnerClass.ThisIsADynamicNamedInnerClass 
16               dnic = aic.getAnInstance(); 
17    
18    
19       AnonymousInnerClass.ThisIsAStaticNamedInnerClass 
20               snic = new AnonymousInnerClass.ThisIsAStaticNamedInnerClass(); 
21   } 
22    
23   public class AnonymousInnerClass { 
24       ThisIsADynamicNamedInnerClass getAnInstance() { 
25           return new ThisIsADynamicNamedInnerClass(); 
26       } 
27       public class ThisIsADynamicNamedInnerClass { 
28       } 
29    
30       public static class ThisIsAStaticNamedInnerClass { 
31       } 
32    
33       public static void main(String[] args) { 
34           JPanel jp = new JPanel() { 
35               public void paint(Graphics g) { 
36                   g.drawLine(20, 20, 100, 100); 
37               } 
38           }; 
39    
40       } 
41    
42   } 
43