title: Standards for using inner classes for GUI?
body: <p>I'm wondering about the standard practice with inner classes (in Java but I suppose it applies to all OO languages).
  So I have a JFrame subclass <code>ControllerWindow</code> that contains a JPanel subclass <code>MapPanel</code> which I draw onto (so it needs to overwrite paintComponent method) and which needs to implement a mouse listener. My current solution which works is to have <code>MapPanel</code> in a seperate class implementing MouseListener but when I showed this to the guy who runs my course the other day he seemed to think (we have a bit of a language barrier) this should be in an inner class in <code>ControllerWindow</code> or at least the MouseListener should be an inner class.</p>
  
  <p>So my question is what would be the standard solution here, to put a MouseListener in the inner class, the JPanel in a different inner class or still in its seperate class? The JPanel implementing MouseListener in one inner class? And why?</p>
  
  <p>The most important thing to me is that it works but I'd like to know about and understand the standard practices behind these things if possible.</p>
  
  <p>EDIT: Very simplified version of current code below.</p>
  
  <pre><code>class ControllerWindow extends JFrame{
      ...
      MapPanel drawPanel = new MapPanel();
      ...
  }
  </code></pre>
  
  <p>and a separate class:</p>
  
  <pre><code>class MapPanel extends JPanel implements MouseListener{
  
      ...
  
      public void paintComponent(Graphics g){
          ...//fillRects etc.
      }
  
      //MouseListener methods
      public void mouseReleased(MouseEvent e){
          requestFocus();
          ...
          repaint()
          ...
      }
      public void mousePressed(MouseEvent e){}
      public void mouseEntered(MouseEvent e){}
      public void mouseExited(MouseEvent e){}
      public void mouseClicked(MouseEvent e){}
  }
  </code></pre>
  
  <p>Also could this be a situation where it would be acceptable to put both classes in the same file? I don't envisage using <code>MapPanel</code> for anything other than <code>ControllerWindow</code>.</p>