Re: Create java image from Jpanel without displaying
From: hiwa (HGA03630_at_nifty.ne.jp)
Date: 12/05/03
- Next message: hiwa: "Re: .equals(o) and Set membership"
- Previous message: Raymond DeCampo: "Re: Java HTML formatter?"
- In reply to: Moth: "Create java image from Jpanel without displaying"
- Next in thread: FISH: "Re: Create java image from Jpanel without displaying"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Next message: hiwa: "Re: .equals(o) and Set membership"
- Previous message: Raymond DeCampo: "Re: Java HTML formatter?"
- In reply to: Moth: "Create java image from Jpanel without displaying"
- Next in thread: FISH: "Re: Create java image from Jpanel without displaying"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|