Boyu Sun
Boyu Sun

Reputation: 17

JFreeChart: ChartMouseClicked not working

I'm using the JFreeChart library and created a chartPanel with chartMouseListener. What is strange is that the chartPanel did respond to chartMouseMove event but the chartMouseClicked is never trigger even though I've clicked very hard.

Any one can throw some light upon this issue? Really appreciated!

Upvotes: 0

Views: 688

Answers (1)

robthewolf
robthewolf

Reputation: 7624

With out seeing your, code it is quite hard to guess what it going on. You must implement ChartMouseListener somewhere and then add it to the chart panel.

public class MyChart implements ChartMouseListener 

later

chartPanel.addChartMouseListener(this)

then override the the chartMouseClicked method

@Override
public void chartMouseClicked(ChartMouseEvent e){
    if(e.getTrigger().getButton() ==  MouseEvent.BUTTON1) {
        //do something interesting
    }
}

Upvotes: 1

Related Questions