3

This is the code I'm currently using:

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

2 Answers 2

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

});
Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.