removing mouseListener
Hi,
i have a table and have added to the header some mouselistener on it.
How can i remove it ?
Code example.
JTable.getTableHeader().addMouseListener(new MouseAdapter ()
{public void mousePressed( MouseEvent event )
{
rightMouseClicked( event );
}
});
How can i remove this listener ?
Regards.
[369 byte] By [
Wolfstone] at [2007-9-27 22:04:32]

You can't.
Since you lack the reference to the innerclass object, there is no way for you to remove it.
The alternative would be to do:
MouseListener ml = new MouseAdapter ()
{
public void mousePressed( MouseEvent event )
{
rightMouseClicked( event );
}
});
jtable.getTableHeader().addMouseListener(ml);
Now you can later use ml reference to remove it as listener.
Example:
jtable.removeTableHeader().addMouseListener(ml);