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?!
validate() is usually invoked which results in the updating of the container and it's parents. Im not sure if this method can be called explicitly but it's worth a try.
Hrm, i called validate, but it pretty much gave me the same results.
Do you reckon it could because its a JDesktopPane, that is not scrollable, so it dosen't know its got anyhting outside of the view port.... know what i mean?!
is there an easy way to get a JDesktopPAne to scroll?!? i already know that you can't simply add it to a JScrollPane.. no that would be to easy!