Re: Create java image from Jpanel without displaying

From: hiwa (HGA03630_at_nifty.ne.jp)
Date: 12/05/03


Date: 4 Dec 2003 21:21:25 -0800


"Moth" <no@email.here> wrote in message news:<Se7zb.36702$aT.19778@news-server.bigpond.net.au>...
> I have a PlotPanel class that extends JPanel which I have used previously to
> display charts in swing guis. I now want to display a graph in a jsp page
> so I was going to generate the graph and then save it to a jpeg and then
> display it in the page.
>
> Is there anyway to create an Image from a JPanel without actually displaying
> it in a JFrame first? Can anyone suggest a better way to create a chart
> image for servlet/jsp?
If the plotted chart, not the JPanel component itself, does matter,
draw(or plot) the chart into a BufferedImage and write it to your .jpg
or .png file. You can get the Graphics/Graphics2D object for drawing
from BufferedImage#createGraphics() method. If you reuse your
PlotPanel#paint() method, developing time could be an instant.

Unfortunately it seems we still don't have convenient APIs for
capturing Java GUI component as an Image and for storing them onto
standard image files.



Relevant Pages

  • Re: More CChildFrame questions
    ... I do not deny usability of anything, but have I have tried to design my ... you have confused data with computation with display and lumped ... The code to calculate graph chart points is in the chart classes. ... confusing computation of results and displays of results. ...
    (microsoft.public.vc.mfc)
  • Re: Charting Question
    ... I want to change the displayed lines on the chart. ... "Duane Hookom" wrote: ... as the SQL property of a saved query. ... the data you want to display ...
    (microsoft.public.access.reports)
  • Re: Gantt Chart
    ... a chart on standard workweeks, Monday through Friday, and to label ... Now all this is displayed on one sheet but then actually calculated ... For instance, on my main sheet, I display the ... Thanks again go to Jon Peltier who has almost ...
    (microsoft.public.excel.charting)
  • Re: Is there some website that will allow me to plot star maps with labelled magnitudes?
    ... the AAVSO yahoo newsgroup. ... The "Save" button exports a fits image of the display and a text table ... the relevant magnitude by first applying a magnitude filter. ... The AAVSO also has a beta test chart generator. ...
    (sci.astro.amateur)
  • Re: isit possible to display the .mpp file (trhe gantt chart) on t
    ... think there is some APIs to display the .mpp file on the web, ... chart, the project that i published to the server. ... in order to dispaly the .mpp file, isit i got to study all the source ... >> do you know how to display the gantt chart from MS ...
    (microsoft.public.project.vba)