problem with overriding code and deploying an applet

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
annac
Posts: 24
Joined: Mon Oct 01, 2007 7:56 pm
Location: Canada

problem with overriding code and deploying an applet

Post by annac » Mon Oct 15, 2007 9:27 pm

I am deploying my program in an applet and I have run into problems with overriding the ChartPanel class by placing a copied/modified version in an org.jfree.chart package within my project. Applets (in browsers) search the archive .jar files before searching files in your codebase, therefore opening the applet in a browser causes the applet to load the org.jfree.chart.ChartPanel class from the jfree .jar file instead of my copied/modified org.jfree.chart.ChartPanel class inside my project.

I have tried to place my modified ChartPanel class in a different package and remove the import org.jfree.chart.ChartPanel statement from my main class but I have not been able to check if it works yet due to caching problems with my browsers..

Has anyone run into the same problem before or have any ideas on how to fix it?

Thank you!

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Mon Oct 15, 2007 9:50 pm

What you are doing here is deepest and ugliest hacking. Dont do it.

If you cant use subclassing of the ChartPanel to bring your changes in, then you should copy the sources of that class, and place it into a different package. The ChartPanel is not referenced elsewhere (except in demo-code) so there is no sane need to try to replace the class the way you do it. Subclass or copy it under a new name/position.

And if you really have to change the code for the ChartPanel, then download the sources of JFreeChart, change the chart-panel there and then rebuild the jar. This is at least a lot cleaner than what you do right now.

annac
Posts: 24
Joined: Mon Oct 01, 2007 7:56 pm
Location: Canada

Post by annac » Mon Oct 15, 2007 9:56 pm

My apologies. That way was recommended to me. I am new to working with open source projects so I am not familiar with protocol or best practices. And yes, I need to access some of the private fields and modify methods in the ChartPanel class so copying the source seemed the easiest way to access them.

Thank you for your input

Locked