how to listen for clicks in Java (JFreeChart) using events?

隐身守侯 提交于 2019-11-26 06:09:13

问题


This is the code I\'m currently using:

@Override
public void mouseExited(MouseEvent e) {
    System.out.println(\"detectado\");
}

回答1:


You can use addChartMouseListener() to add a ChartMouseListener to your ChartPanel. For example, in BarChartDemo1, add the following:

chartPanel.addChartMouseListener(new ChartMouseListener() {

    public void chartMouseClicked(ChartMouseEvent e) {
        System.out.println(e.getEntity());
    }

    public void chartMouseMoved(ChartMouseEvent e) {}

});



回答2:


To listen for clicks, you must check the type of event.

In particular, you override the

public void mouseClicked(MouseEvent ev) 

method, which is part of the interface for MouseListeners.

For a fill example see : this link



来源:https://stackoverflow.com/questions/8218853/how-to-listen-for-clicks-in-java-jfreechart-using-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!