...
>I have a question.
Do you? I don't see it. A question would usually be followed by
a question mark '?'. The question marks denotes a question. It
also helps the reader to quickly identify the question in usenet posts.
I encourage the use of one (approrpriately applied) question mark in
each post.
>...I have a JPanel with some custom drawings on it like
>rectangles, circles etc. Now I want
>to export The Jpanel as a PBM file.
Why PBM? I had to google to find that was some sort
of monochrome (ick) image format.
Why not save as PNG?
>...I have no idea how to do this.
>
>Maybe someone can point me to some url where I can read how to do it.
Here are two methods from the WebStartFrame I am developing.
They might get you started..
public static BufferedImage getScreenShot(
Component component) {
BufferedImage image = new BufferedImage(
component.getWidth(),
component.getHeight(),
BufferedImage.TYPE_INT_RGB
);
// call the Component's paint method, using
// the Graphics object of the image.
component.paint( image.getGraphics() );
return image;
}
public void saveScreenShot(BufferedImage image) {
getLogger().log(Level.FINEST, "Default saveScreenShot");
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// write the image as a PNG
ImageIO.write(
image,
"png",
baos);
byte[] bytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
saveFileDialog(null, null, bais, null);
} catch(Exception e) {
handleError(e);
}
}

Signature
Andrew Thompson
http://www.athompson.info/andrew/