File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Saving a JDialog using ImageIO giving many problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Saving a JDialog using ImageIO giving many problems" Watch "Saving a JDialog using ImageIO giving many problems" New topic

Saving a JDialog using ImageIO giving many problems

Repala Madhu

Joined: Jun 12, 2007
Posts: 14
Hi Ranchers,

I am saving a JDialog of sige 8000 X 8000 by using ImageIO.

In my project one JInternalFrame of size 600 X 600 is there, I have a network topology (Ring) on that, It has zoom in and zoom out fecility, if i save the same dialog box the topology which is there on that, that much only i could have save as an image. So i am taking the panal of that InternalFrame and adding to JDialog. and saving this dialog box which is of size 8000 X 8000 by using ImageIO.

to save this dialog box it is taking more than 15 mins.

How can i decrease the saving time,

My project main frame is freezing while saving this dialog box,
How could i stop freezing.

And i want to show a progress bar while saving the image, but this progress bar is getting visible after saving the image, and unfortunately this progress bar is adding the my saving image.

Can anybody help me in this regard.

Thanks in adwans.
Repala Madhu

Joined: Jun 12, 2007
Posts: 14
Hi all the code i am using is

* Create a BufferedImage for given component.
* Opens a Save dialog box, takes the location to save.
* All or part of the component can be captured to an image.
*@param component Swing component to create image from
* */

private void saveDtv(Component component,String fileName)
if (fileName != null)
File name=new File(fileName);
BufferedImage image =new BufferedImage( component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB);

Graphics2D g = image.createGraphics();
}catch(Exception ex)
Log.gLog().debug("In createImage() Error while image capture:",ex);
Brian Cole
Ranch Hand

Joined: Sep 20, 2005
Posts: 878
If it's really an 8000x8000 image, that's on the order of 200MB of raw data before PNG compression. Could it be that this has nothing to do with your dialog or Swing and that writing almost any 8000x8000 PNG would take that long?

things that I wonder:

A) What kind of screen do you have that can display a 8000x8000 pixel dialog box?

B) Does it really make sense to store a dialog box as an image?

C) Would it work any better if you used TYPE_BYTE_INDEXED instead of TYPE_INT_RGB?

bitguru blog
I agree. Here's the link:
subject: Saving a JDialog using ImageIO giving many problems
It's not a secret anymore!