chartMouseClicked(ChartMouseEvent event)



Share on Google+Share on Google+

chartMouseClicked(ChartMouseEvent event)
1 Answer(s)      6 years and 9 months ago
Posted in : JSP-Servlet

Hi deepak ihave draw a piechart using jfreechart with tooltip.Now i need click event (chartMouseClicked(ChartMouseEvent event)) in this chart. can u help me plz....

View Answers

February 18, 2011 at 3:40 PM

Java JFreechart MouseEvent

import java.awt.*;
import javax.swing.*;
import org.jfree.ui.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.entity.*;

public class PieChart extends ApplicationFrame implements ChartMouseListener {
private JFreeChart chart; 
private PiePlot plot;
private int angle=270;
private static double explodePercent = 0.99;
private static long count=0;

public PieChart(String title){
        this.chart = ChartFactory.createPieChart("Pie Chart Demo",createDataset(),  true,  true, false);
        this.plot = (PiePlot) chart.getPlot();
        this.plot.setNoDataMessage("No data available");
        ChartPanel chartpanel = new ChartPanel(chart, false, false, false, false, false);   
        chartpanel.setPreferredSize(new Dimension(500, 270));
private static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("One", new Double(10.0));
    dataset.setValue("Two", new Double(20.0));
    dataset.setValue("Three", new Double(30.0));
    dataset.setValue("Four", new Double(40.0));
    dataset.setValue("Five", new Double(10.0));
    return dataset;
private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart3D("Pie Chart Demo",dataset, true, true,false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setNoDataMessage("No data available");
    return chart;
public static JPanel createDemoPanel() {
    JFreeChart chart = createChart(createDataset());
    ChartPanel chartpanel = new ChartPanel(chart, false, false, false, false, false);   
    chartpanel.setPreferredSize(new Dimension(500, 270));
    return new JPanel();
public static void main(String[] args) {
    PieChart demo = new PieChart("Pie Chart");
public void chartMouseClicked(ChartMouseEvent chartmouseevent){
ChartEntity chartentity = chartmouseevent.getEntity();
if (chartentity != null){
   System.out.println("Mouse clicked: " + chartentity.toString());
System.out.println("Mouse clicked: null entity.");

public void chartMouseMoved(ChartMouseEvent chartmouseevent){


Related Tutorials/Questions & Answers:
chartMouseClicked(ChartMouseEvent event)
chartMouseClicked(ChartMouseEvent event)  Hi deepak ihave draw a piechart using jfreechart with tooltip.Now i need click event (chartMouseClicked(ChartMouseEvent event)) in this chart. can u help me plz
event handling
event handling  diff btwn event handling in and in HTML
Event Listeners
Event Listeners  I want to learn the Event Listeners in Java. Any... is the good tutorial and example of Event Listeners in Java. Please check the tutorial Java - Event Listeners Example in Java Applet. Thanks
Flex event
Flex event  Hi.... please tell me about How does Flex event system works? Thanks  Ans: When event are triggered there are three...: In the capturing phase, Flex examines an event target?s ancestors in the display list to see
Event in flex
Event in flex  Hi..... can you tell me about that How do you make component participate in event mechanism? Thanks   Ans: Extend EventDispatcher or any subclass of it or implement IEventDispatcher
Event management
Event management   Hi, I want event management application like maintaining email notifications while task creation and update in broader way using spring java
Event in flex
Event in flex  Hi..... I want to know about What does calling preventDefault() on an event do? How is this enforced? please give me an example for that Thanks   Ans: The methods of the Event class can be used
Flex event
Flex event  Hi... please give me the answer with example What is event Bubbling? Thanks in advance  Event Bubbling: In the bubbling phase, Flex examines an event?s ancestors for event listeners. Flex starts
Flex event
Flex event  hi...... How to capture and event if the component is disabled? please give an example..... Thanks in advance
Flex event
Flex event  Hi.... Please tell me about How to create your own event in flex? Thanks
Click event
Click event  hi............ how to put a click event on a particular image, so that it can allow to open another form or allow to display result in tabular form????????/ can u tell me how to do that????????/ using java swings
Version of d-haven-event>event dependency
List of Version of d-haven-event>event dependency
Version of excalibur-event>excalibur-event dependency
List of Version of excalibur-event>excalibur-event dependency
Java event handling
Java event handling  What event results from the clicking of a button
How to Handle Event Handlers?
How to Handle Event Handlers?  How to Handle Event Handlers
handling Button Event in iphone
handling Button Event in iphone  handling Button Event in iphone
Java event-listener
Java event-listener  What is the relationship between an event-listener interface and an event-adapter class
Java event delegation model
Java event delegation model  What is the highest-level event class of the event-delegation model
Version of excalibur-event>excalibur-event-api dependency
List of Version of excalibur-event>excalibur-event-api dependency
Version of excalibur-event>excalibur-event-impl dependency
List of Version of excalibur-event>excalibur-event-impl dependency
Event helpers
Event helpers       Event helpers As we all know events are actions or occurrences detected by a program. And event handlers are methods which handles
Event listener in JavaScript with example
Event listener in JavaScript with example  What is event listener in JavaScript? Can anyone please post an example of Event listener?? Thanks in Advance
Java event-delegation model
Java event-delegation model  What is the advantage of the event-delegation model over the earlier eventinheritance model
Java event handling
Java event handling  Which java.util classes and interfaces support event handling
Event handling on an image
Event handling on an image  I want to divide an image into frames and want to do event handling on the frames
delegation event model
delegation event model  What is delegation event model?   delegation event model In the event-delegation model, specific objects are designated as event handlers for GUI components. These objects implement event
Java AWT event hierarchy
Java AWT event hierarchy  What class is the top of the AWT event hierarchy?  The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy
event calendar sample
event calendar sample  creating a event calendar for my small app in PHP.. can any one explain about it's design with example php event calendar script
Java event handling
Java event handling  What is the purpose of the enableEvents() method
Version of d-haven-event>d-haven-event dependency
List of Version of d-haven-event>d-haven-event dependency
event tracking code
event tracking code  a javascript written that will help us to track sitewide, even tracking in Google Analytics


Advertisement null