title: Add a listener to JFrame and all subcomponents
body: <p>In a Swing project, I have used a <code>JFrame</code> and divided it into three parts: a <strong><em>menu pane</em></strong>, a <strong><em>context pane</em></strong>, and a <strong><em>status pane</em></strong>.</p>
  
  <p>The status pane shows to the user whether his actions was successful or not, along with other information that the user might want to know, upon taking an action. For example, if the user clicks a delete button in the context menu, the status panel indicates whether the operation was done successfully.</p>
  
  <p>The problem with the status panel is that it needs to update its status after a while. For instance, if the user clicks on another button or navigates through other pages in the context pane, the status pane shouldn't be still showing the results of the last delete operation.</p>
  
  <p>There are two workarounds for this, that I can think of: </p>
  
  <ol>
  <li>clear the status after a few seconds. </li>
  <li>add an mouse or keyboard action listener to all of the components(<code>JPanels</code>, <code>JTextFields</code>, and ...) so that they call the status panel to clear the status, upon an activity from the mouse or keyboard.</li>
  </ol>
  
  <p>Although implementing the first option is relatively simple, but it's not enough. I think I need a combination of the two. However the problem is that it would be a very dirty approach if I want to add these action listeners to all the components. Maybe I can add it to the main frame. I did (the code is given below), but if works only if the mouse is moving on the frame's own panel (not on the context pane, for example)</p>
  
  <p>Do you have any suggestions?</p>
  
  <pre><code>    JFrame.this.addMouseMotionListener(new MouseMotionListener() {
  
          @Override
          public void mouseDragged(MouseEvent me) {
          }
  
          @Override
          public void mouseMoved(MouseEvent me) {
              Config.statusPanel.clearStatus();
          }
      });
  </code></pre>