setContentPane miss

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
canerandagio
Posts: 8
Joined: Thu Feb 07, 2019 5:49 pm
antibot: No, of course not.

setContentPane miss

Post by canerandagio » Thu Feb 07, 2019 5:52 pm

Code: Select all

setContentPane( chartPanel );
I got error The method setContentPane(ChartPanel) is undefined for the type registro_spesa
I have /home/andrea/java/jfreechart-1.0.19/lib/jfreechart-1.0.19.jar imported in my project

John Matthews
Posts: 483
Joined: Wed Sep 12, 2007 3:18 pm

Re: setContentPane miss

Post by John Matthews » Fri Feb 08, 2019 3:40 am

The same fragment works in the demos, either old or new.

canerandagio
Posts: 8
Joined: Thu Feb 07, 2019 5:49 pm
antibot: No, of course not.

Re: setContentPane miss

Post by canerandagio » Fri Feb 08, 2019 9:43 am

are u sure setContentPane is a method of JfreeChart class? i found it here https://docs.oracle.com/javase/6/docs/a ... Frame.html
it seems that it is a method of swing.

John Matthews
Posts: 483
Joined: Wed Sep 12, 2007 3:18 pm

Re: setContentPane miss

Post by John Matthews » Fri Feb 08, 2019 2:22 pm

Yes, I am sure; setContentPane() is a method of the JFreeChart class org.jfree.chart.ui.ApplicationFrame. Note that ApplicationFrame is a JFrame, from which it inherits setContentPane(). The JFreeChart class org.jfree.chart.JFreeChart is not a Swing component, and it has no such method.

canerandagio
Posts: 8
Joined: Thu Feb 07, 2019 5:49 pm
antibot: No, of course not.

Re: setContentPane miss

Post by canerandagio » Fri Feb 08, 2019 3:40 pm

From http://www.jfree.org/jfreechart/api/jav ... Frame.html it say that it is under javax.swing.JFrame. :roll: and I 've not org.jfree.chart.ui,* in my library :roll: :?: :?:

John Matthews
Posts: 483
Joined: Wed Sep 12, 2007 3:18 pm

Re: setContentPane miss

Post by John Matthews » Fri Feb 08, 2019 5:20 pm

You appear to be using an earlier version from a time when org.jfree.ui.ApplicationFrame was in a separate library. Either switch to the new version or add the required JAR to your class path, as shown here.

canerandagio
Posts: 8
Joined: Thu Feb 07, 2019 5:49 pm
antibot: No, of course not.

Re: setContentPane miss

Post by canerandagio » Fri Feb 08, 2019 6:54 pm

I've checked, i have both jfreechart-1.0.19.jar and jcommon-1.0.23.jar :roll: :roll:
are there others solutions?

canerandagio
Posts: 8
Joined: Thu Feb 07, 2019 5:49 pm
antibot: No, of course not.

Re: setContentPane miss

Post by canerandagio » Fri Feb 08, 2019 7:36 pm

The most recent version i found is 1.0.19

John Matthews
Posts: 483
Joined: Wed Sep 12, 2007 3:18 pm

Re: setContentPane miss

Post by John Matthews » Sat Feb 09, 2019 10:16 am

You can test your existing version like this:

Code: Select all

$ cd /jfreechart/lib
$ java -cp jfreechart-1.0.19.jar:jcommon-1.0.23.jar org.jfree.chart.demo.BarChartDemo1
The current release is cited here.

canerandagio
Posts: 8
Joined: Thu Feb 07, 2019 5:49 pm
antibot: No, of course not.

Re: setContentPane miss

Post by canerandagio » Sat Feb 09, 2019 6:44 pm

Ok thanks, i ll try on monday

canerandagio
Posts: 8
Joined: Thu Feb 07, 2019 5:49 pm
antibot: No, of course not.

Re: setContentPane miss

Post by canerandagio » Mon Feb 11, 2019 10:46 am

I reiterate that setContentPane is a method of javax.swing.JFrame class, it is written here http://www.jfree.org/jfreechart/api/jav ... Frame.html

John Matthews
Posts: 483
Joined: Wed Sep 12, 2007 3:18 pm

Re: setContentPane miss

Post by John Matthews » Tue Feb 12, 2019 1:04 pm

I cited examples using org.jfree.chart.ui.ApplicationFrame, and you mention org.jfree.chart.ChartFrame; both are subclasses of javax.swing.JFrame, which provides setContentPane(). When using either, be sure to construct and manipulate Swing GUI objects _only_ on the event dispatch thread.

Post Reply