title: better way to implement inner class with listeners
body: <p>I have a main class with inner classes. This is a swing/GUI application.</p>
  
  <p>I have inner classes that are swing related such as extending JPanel, JDialog etc...</p>
  
  <p>Inside the inner classes I have anonymous classes such as action listeners which I have to set and get data from the outer class..</p>
  
  <p>For example main class has inner class and inside inner class I have an anonymous listener class such as this:</p>
  
  <pre><code>public class Main extends JApplet {
   //etc...
    private class CTable extends JPanel {
        CDialog td;
        private JPopupMenu menu;
        public CTable(String title, AbstractTableModel tableModel) {
           //etc...
           menu = new JPopupMenu();
           JMenuItem menuItem = new JMenuItem("Test");
           menu.add(menuItem);
           //etc...
           menuItem.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent event) {
                CTable.this.td = new CDialog("Test");
                CTable.this.td.setVisible(true);
             }
           });
       }
  
  }
  </code></pre>
  
  <p>My only question is only related to whether its good practice to access the variable like this: <strong>CTable.this.td = new CDialog("Test");
  CTable.this.td.setVisible(true);</strong>
  ...from anonymous classes and suggestions on different implementation strategies/design patterns.</p>