0
votes

I need to make a copy of an existing JFreechart and associate it several times with a mouse click Here is what I was trying:

public void chartMouseClicked(ChartMouseEvent event) 
{ 
    JFreeChart tempChart = existingChart;
    ChartPanel panel = new ChartPanel(tempChart);
    //View Frame
}

The same variable is used several times. The problem I encounter is, the previous chart also gets replaced when I make the second mouse click.

Is there a way to create a fresh copy somehow ?

1
Did you try clone() yet?Charles Goodwin
Clone does work. I need to manually enable the pan and zoom functionality though.chrisrhyno2003

1 Answers

1
votes

As discussed in the comments, use the standard Object function clone() to copy objects in the majority of circumstances.

For the record, all I did was look up the JFreeChart javadoc to check. Documentation is your friend.