problem displaying the background image

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Joachim Schuler

problem displaying the background image

Post by Joachim Schuler » Wed Jul 31, 2002 9:48 am

Hi,

I have a problem displaying the background image

if I display by Chart the first time, after I started my Tomcat, the background will not be displayed.

After i update my browser window, or start the application in a new browser, the background will be displayed correctly.

Have I made a mistake in displaying the chart ?

---- source -----

public JFreeChart createChart (){
...
JFreeChart chart = ChartFactory.createTimeSeriesChart("","Daimler Chrysler AG" ,"",subData1,false);

String chartbackground = "C:\Charttemplates\shorttermTS.gif";

Image backgroundImage = Toolkit.getDefaultToolkit().getImage(chartbackground);
chart.setBackgroundImage(backgroundImage);
chart.setBackgroundImageAlpha( (float) (1.0));
...
return chart;
}

public void doGet(...') {
JFreeChart chart = createChart();
OutputStream out = response.getOutputStream();
ChartUtilities.writeChartAsPNG(out, chart, width, height);
out.close();
}

Thanks

Joachim Schuler

David Gilbert

Re: problem displaying the background image

Post by David Gilbert » Wed Jul 31, 2002 5:19 pm

I usually use the ImageIcon class to load images, it tends to be easier. See this link for more info:

http://java.sun.com/docs/books/tutorial ... mages.html

Regards,

DG.

Joachim Schuler

Re: problem displaying the background image

Post by Joachim Schuler » Fri Aug 02, 2002 10:20 am

Thanks a lot,

this solved by problem.

now I use the mentioned ImageIcon class.

Guido Laures

Re: problem displaying the background image

Post by Guido Laures » Fri Aug 02, 2002 12:30 pm

To avoid a dependency on Swing one can also use the utility class util.ImageHelper from the Cewolf project which uses a loading mechanism equal to the one of the ImageIcon class.

chris k.

Re: problem displaying the background image

Post by chris k. » Mon Aug 19, 2002 11:11 am

Hi,

how exactly did you use the ImageIcon class. My problem is, that there only is a method setBackgroundImage(Image image), and i can not convert ImageIcon to Image.

Thanx, Chris.

Locked