freesoft_2000 9 Practically a Master Poster

Hi everyone,

I have a bit of a problem converting a JTextPane to an image.
I am able to convert the JTextPane to a PNG image but its quality is really bad. Is there a way that i can convert my JTextPane to a high quality image.

The type of image format does not matter

Here is what i have so far

public void export(JComponent Component) 
{

  File f1 = new File("C:\\Temp.PNG");
  Dimension Size5 = Component.getSize();  
  BufferedImage Image1 = new BufferedImage(Size5.width, Size5.height,  BufferedImage.TYPE_INT_ARGB);	
  Graphics2D g2 = Image1.createGraphics();		
  g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC);
  Component.paint(g2);	

try
{
     ImageIO.write(Image1, "PNG", f1);
}

catch (Exception e)
{
     e.printStackTrace();
}

}

I hope someone can help with this problem

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.