Andy_Hollywood
Aug 21st, 2003, 10:15 AM
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:
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
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:
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