Chartmouselistener overriding tooltips?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
Posts: 1
Joined: Mon Mar 19, 2018 1:50 pm
antibot: No, of course not.

Chartmouselistener overriding tooltips?

Post by bansidhe » Fri Oct 05, 2018 7:48 pm


I am using a combined plot. I set tool tips using the custom generator. I then added a chartmouselistener that creates annotations when points on the bottom plot are clicked.
Anyway, I noticed my tool tips stopped appearing after I added the listener. So, then I commented out the add listener. Voila, the tool tips appeared again.

Below is the code: If you see something that is causing this issue or have any suggestions I would appreciate it. Thanks.

CustomXYToolTipGenerator ttg= new CustomXYToolTipGenerator();
---- ttg is filled with tooltips for points on the top plot ----

CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(new NumberAxis(Xlabel));

// add the subplots...
cplot.add(PLOT1, 10);
cplot.add(PLOT2, 1);

JFreeChart chartPanel = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, cplot, true);



ChartListener chartMouseListener = new ChartListener(null);

public class ChartListener implements org.jfree.chart.ChartMouseListener {

XYDataset dataset;

public ChartListener(XYSeriesCollection dataset) {
this.dataset = dataset;

public void setDataset(XYDataset indataset) {
this.dataset = indataset;

public void chartMouseClicked(ChartMouseEvent cme) {

if (cme.getEntity() == null) {

XYItemEntity xyitem = (XYItemEntity) cme.getEntity();

int i = 0;

if (dataset == xyitem.getDataset()) {
if (xyitem.getSeriesIndex() == 0) {

double x = dataset.getXValue(xyitem.getSeriesIndex(), xyitem.getItem());
double y = dataset.getYValue(xyitem.getSeriesIndex(), xyitem.getItem());
XYLineAnnotation a2 = new XYLineAnnotation(x, 0.0, x, Math.abs(y));
if (xy.getTopPlot().getAnnotations().contains(a2)) {

else {
}// otherwise it is the top plot that was clicked. }

public void chartMouseMoved(ChartMouseEvent cme) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.


Post Reply