removing listener from ChartPanel

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
lia
Posts: 18
Joined: Sat Oct 14, 2006 5:02 am
Location: Victoria BC

removing listener from ChartPanel

Post by lia » Fri Jun 22, 2007 8:35 pm

Could you please give me example code for how to remove a listener.? I find your example code very helpful. I have read the api but I don't seem to be implementing what is required as I am getting errors.

chartPanel.removeChartMouseListener(ChartMouseListener.class); //error ChartMouseListener cannot be resolved to a type

chartPanel.removeChartMouseListener(TrendLineMouseListener.class);// is not applicable to the arguments

EventListener[] listeners = chartPanel.getListeners(ChartMouseListener.class);//gets the error ChartMouseListener cannot be resolved to a type.

Thank you

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Fri Jun 22, 2007 9:30 pm

Code: Select all

// MyChartMouseListener implements ChartMouseListener ...obviously
ChartMouseListener cml = new MyChartMouseListener();
chartPanel.addChartMouseListener(cml);
//
// Do something
//
chartPanel.removeChartMouseListener(cml);

Post Reply