Results 1 to 4 of 4

Thread: Component to a JPEG and i enclose a piccy!

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    UK
    Posts
    222

    Component to a JPEG and i enclose a piccy!

    Hello

    I have a JDesktopPane with some internal windows, and an extra
    JPanel in one of the layers!

    havea look att he picture attachment and you'll undertsand what i mean.

    I'd like to output what i have inthe desktop area to a JPEG, now i can output to a JPeg fine with this code:

    Code:
    try{
    		//	component.setBackground(Color.WHITE);
    			Dimension d = component.getPreferredSize();
    			BufferedImage bimage = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB);
    
    			component.paintImmediately(new Rectangle(d.width, d.height));
    			component.paintAll(bimage.createGraphics());
    			//component.paint(bimage.createGraphics());
    			
    			
    			if(!path.endsWith(".jpg"))
    				path += extension;
    			OutputStream out = new FileOutputStream(path);			
    			ImageIO.write(bimage, "jpeg", out);
    			out.close();		
    		}catch (Exception e){
    			System.out.println(e);
    		}

    Now the problem i am having is when i move an internal frame so half of it is hidden by the edge of the sccreen and i print i end upw oith the image that is on the left hand side, i.e. the big black line, now i change the preffered size of the desktop to the MAX X,Y locatiosna dn widths of any internal frame, so it will alway return the full area.

    Now the printing works fine, if you look at the one onthe right, its drawn my diagrma ok, i was wondering if i am missing somehting, or if there is another way to force the dekstop pane to repaint everyhting in it?!

    does that make sense?! hope so

    if not let me know and i'll have another stab.

    Cheers

    Andy
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width