title: addMouseListener to a program
body: <p>im trying to overwrite <code>mouseClicked</code> function of <code>MouseAdapter</code> then i can use it in my program as follow:</p>
  
  <pre><code>import java.awt.Component;
  import java.awt.event.MouseAdapter;
  import java.awt.event.MouseEvent;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.Reader;
  import java.net.URL;
  import java.net.URLConnection;
  import javax.swing.JFrame;
  import javax.xml.parsers.ParserConfigurationException;
  import org.lobobrowser.html.HtmlRendererContext;
  import org.lobobrowser.html.UserAgentContext;
  import org.lobobrowser.html.domimpl.HTMLLinkElementImpl;
  import org.lobobrowser.html.gui.HtmlPanel;
  import org.lobobrowser.html.parser.DocumentBuilderImpl;
  import org.lobobrowser.html.parser.InputSourceImpl;
  import org.lobobrowser.html.test.SimpleHtmlRendererContext;
  import org.lobobrowser.html.test.SimpleUserAgentContext;
  import org.w3c.dom.Document;
  import org.w3c.dom.html2.HTMLLinkElement;
  import org.w3c.dom.html2.HTMLElement;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  
  public  class test {
  
  
  
  public static void main(String[] args) throws SAXException, 
              IOException, ParserConfigurationException {
  
          String uri = "http://docs.oracle.com/javase/1.5.0/docs/api/java/awt/event/MouseAdapter.html";
          URL url = new URL(uri);
          URLConnection connection = url.openConnection();
          InputStream in = connection.getInputStream();
          Reader reader = new InputStreamReader(in);
          InputSource is = new InputSourceImpl(reader, uri);
          UserAgentContext uAgent = new SimpleUserAgentContext();
          final HtmlPanel htmlPanel = new HtmlPanel();
          final HtmlRendererContext rendererContext = (HtmlRendererContext) 
                  new LocalHtmlRendererContext(htmlPanel, uAgent);
          DocumentBuilderImpl builder = new DocumentBuilderImpl(uAgent, rendererContext);
          Document document = builder.parse(is);
          JFrame frame = new JFrame();
          frame.setContentPane(htmlPanel);
  
  
          htmlPanel.addMouseListener(new MouseAdapter() {
  
              @Override
              public void mouseClicked(MouseEvent e) {
                  System.out.println("adr is equal to" + rendererContext.getCurrentURL());
  
                  System.out.println("Clicked!" + e);
              }
          });
  
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          htmlPanel.setDocument(document, rendererContext);
          frame.setSize(400, 800);
          frame.setVisible(true);
      }
  
      private static class LocalHtmlRendererContext extends SimpleHtmlRendererContext {
  
          public LocalHtmlRendererContext(HtmlPanel contextComponent, UserAgentContext uAgent) {
              super(contextComponent);
          }
      }
  }
  </code></pre>
  
  <p>but it is not working. if i clik on any part of the form, nothing happens.</p>
  
  <p>i tried     <code>htmlPanel.addMouseListener(new MouseAdapter()</code> and     <code>frame.addMouseListener(new MouseAdapter()</code> both but no help.</p>
  
  <p>EDIT:</p>
  
  <p>i tried your suggestion, and i choosed BrowsertPanel instead of HtmlPanel, then i tried to get its component as follow:</p>
  
  <pre><code>org.lobobrowser.gui.AddressBarPanel[,0,0,0x0,invalid,layout=javax.swing.BoxLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
  org.lobobrowser.gui.SharedToolBarPanel[,0,0,0x0,invalid,layout=javax.swing.BoxLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
  org.lobobrowser.gui.FillerComponent[,0,0,0x0,invalid,layout=org.lobobrowser.util.gui.WrapperLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=java.awt.Dimension[width=32767,height=32767],minimumSize=java.awt.Dimension[width=0,height=0],preferredSize=java.awt.Dimension[width=32767,height=32767]]
  org.lobobrowser.gui.StatusBarPanel[,0,0,0x0,invalid,layout=javax.swing.BoxLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.border.BevelBorder@c2a132,flags=9,maximumSize=,minimumSize=,preferredSize=]
  </code></pre>
  
  <p>also i added a navigationListener and when it navigates, i get the event as follow:</p>
  
  <pre><code>org.lobobrowser.ua.NavigationEvent[source=FramePanel[windowId=BrowserPanel.10481519,hashCode=23491286,parent=org.lobobrowser.gui.FillerComponent[,0,25,584x316,layout=org.lobobrowser.util.gui.WrapperLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=java.awt.Dimension[width=32767,height=32767],minimumSize=java.awt.Dimension[width=0,height=0],preferredSize=java.awt.Dimension[width=32767,height=32767]]]]
  </code></pre>
  
  <p>but i feel im lost in these components, it seems the <code>FillerComponent</code> or <code>FramePanel</code> are responsible for rendering, even so, i have no idea how to add listener to  them.</p>
  
  <p>also found this <a href="http://sourceforge.net/projects/xamj/forums/forum/467020/topic/2119642" rel="nofollow">Link</a> that someone described the steps to solve the problem, but seems so complicated to me? is there any pseudocode to distribute?</p>