3

This is the code I'm currently using:

@Override
public void mouseExited(MouseEvent e) {
    System.out.println("detectado");
}
Peter O.
  • 32,158
  • 14
  • 82
  • 96
Maxi Dee
  • 61
  • 2
  • 6

2 Answers2

6

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) {}

});
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
0

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

jayunit100
  • 17,388
  • 22
  • 92
  • 167
  • sorry im new and tried to copy all the code (it's not that much) but i could'nt problem is it doesn't detect anything, i overrided but nothing happens, more ideas? (thx so much for the patience) – Maxi Dee Nov 21 '11 at 22:01