I am trying to export a jcomponent as an image. The program all works but seriously the the quality of the saved image is really disgusting.
The words seems to be blurred. I think i have to use rendereing hints but i am not sure how there work or which hint to use for my situation.
Here is the code i use to convert a jcomponent to an image file
public void exporttableasjpeg(JComponent Component)
FileChooser1.setDialogTitle("Select Export File");
if(FileChooser1.showDialog(fr1, "Export") != JFileChooser.APPROVE_OPTION)
File f = FileChooser1.getSelectedFile();
k = (f.toString() + ".JPG");
Dimension Size4 = Component.getSize();
BufferedImage Image1= new BufferedImage(Size4.width, Size4.height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = Image1.createGraphics();
//I need someone to suggest a good hint to use for this situation
OutputStream out = new FileOutputStream(k);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
catch (Exception e)
Label1.setText("An error exporting the table as an image has occurred");
Basically i need someone to tell me if i am using the rendering hint in the right way and also to recommend an appropriate hint for my situation
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL