Hi all,
I am using
JFreechart 1.0.13 and am stuck at a point where I need to handle mouse click events on the axes. Is there a way to do this in the latest JFreeChart version?? Please do let me know.
Avanidhar
mouse Clicks on axes
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: mouse Clicks on axes
Create a ChartMouseListener and add that to the ChartPanel.
In the chartMouseClicked(ChartMouseEvent event) method, get the ChartEntity of the event (chartMouseEvent.getEntity()), check whether the ChartEntity is an instance of AxisEntity, and if yes, get the axis (axisEntity.getAxis()).
In the chartMouseClicked(ChartMouseEvent event) method, get the ChartEntity of the event (chartMouseEvent.getEntity()), check whether the ChartEntity is an instance of AxisEntity, and if yes, get the axis (axisEntity.getAxis()).
Re: mouse Clicks on axes
thanks paradoxoff,
when i try to do as such
i get a null pointer exception. It seems like the event.getEntity() method is returning a null pointer. any reasons why this could be happening?
when i try to do as such
Code: Select all
ChartEntity entity = event.getEntity();
System.out.println(event.getEntity().toString());
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: mouse Clicks on axes
Difficult to say w/o source code. Can you check whether the entity is indeed null? If that is the case, you might have simply missed the axis.