473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Create java image from Jpanel without displaying

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?
Jul 17 '05 #1
3 13861
RChart includes a servlet which does not needs to display any panel:

http://www.java4less.com/charts_e.htm
"Moth" <no@email.here> wrote in message news:<Se******************@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?

Jul 17 '05 #2
"Moth" <no@email.here> wrote in message news:<Se******************@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.
Jul 17 '05 #3
"Moth" <no@email.here> wrote in message news:<Se******************@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- ><>
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JW | last post by:
Hi, I am trying to see if I can display an animated .gif file on a Java application (that is, I do not want to have to show a series of static images to simulate animateion; I just want to...
2
by: TR | last post by:
Hi All: I have a simple test GUI that has 2 panels (a left side and a right side), and each panel is displaying an image. The left panel has a hardcoded size of (600,400) using the Dimension()...
0
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
1
by: tommyny04 | last post by:
I'm kinda new to programming but I usually figure things out by myself but I need help with this. I'm trying to display an image in the Center region of a JFrame and other icons/button in the other...
2
by: HaifaCarina | last post by:
i have this unfinished java program and i can't figure out what is the problem.. please help... /** * @(#)Answer3.java * * * @author * @version 1.00 2008/1/17
1
eyeofsoul
by: eyeofsoul | last post by:
i have build the gui but i am having problem with implementing the tcp/udp. can somebody help me. i have server and client. the server can chat with the client. when i tried to to use the udp of tcp...
1
by: Akino877 | last post by:
Hello, I have a question regarding Java and Swing programming I wonder if I could ask the forum for some help. I have a JPanel that has a couple of radio buttons and an "OK/Next" button on it. ...
1
by: chanshaw | last post by:
Alright so basically I have a logo named "DirSync.jpg" and I want to display it on the top portion of my application window in a container (either JLabel or JPanel which ever is normally recommended)...
1
by: HxRLxY | last post by:
I have a program that shows a thumbnail of an image. If the user clicks on the thumbnail a new JFrame is opened that shows the full size image. If the image is larger than the screen, it gets...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.