Re: Create java image from Jpanel without displaying
From: FISH (joeking_at_merseymail.com)
Date: 12/05/03
- Previous message: young: "free C compiler under W2000 platform for JNI"
- In reply to: Moth: "Create java image from Jpanel without displaying"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 5 Dec 2003 03:44:04 -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?
I've not tried this personally, but in theory it should work. Create an
Image of the appropriate size to hold the JPanel, get a Graphics object
from it - then call the JPanel's paint() method directly with your own
Graphics object. The component *should* paint itself, and its children,
into your Image in exactly the same way as it does to screen.
-FISH- ><>
- Previous message: young: "free C compiler under W2000 platform for JNI"
- In reply to: Moth: "Create java image from Jpanel without displaying"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|