Hi,
I have a Jpanel containing Jtext,Jlabel,.... (producing a report),When
I tried to print the Jpanel it is takin too much time to reach a
printer(size 3MB!). I think it will be ok if we get hem grayscaled.
Anyone have an idea to graycale a Jpanel or Jframe? I searched in
Google but no use.
Andrey Kuznetsov - 10 Feb 2006 14:28 GMT
> I have a Jpanel containing Jtext,Jlabel,.... (producing a report),When
> I tried to print the Jpanel it is takin too much time to reach a
> printer(size 3MB!). I think it will be ok if we get hem grayscaled.
> Anyone have an idea to graycale a Jpanel or Jframe? I searched in
> Google but no use.
Component contains special method for printing.
You have to override it.
You can create first BufferedImage (TYPE_BYTE_GRAY) and paint everything to
it.
Then paint this image to Graphics.

Signature
Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities
zero - 10 Feb 2006 16:34 GMT
"Mahesh" <registered.here@gmail.com> wrote in news:1139578453.374852.63230
@z14g2000cwz.googlegroups.com:
> Hi,
> I have a Jpanel containing Jtext,Jlabel,.... (producing a report),When
> I tried to print the Jpanel it is takin too much time to reach a
> printer(size 3MB!). I think it will be ok if we get hem grayscaled.
> Anyone have an idea to graycale a Jpanel or Jframe? I searched in
> Google but no use.
try this:
BufferedImage img = new BufferedImage(jPanel.getWidth(),
jPanel.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
jPanel.paintComponent(img.getGraphics());
// print img
or:
BufferedImage img = new BufferedImage(jPanel.getWidth(),
jPanel.getHeight(), BufferedImage.TYPE_INT_RGB);
jPanel.paintComponent(img.getGraphics());
Image grayImage = GrayFilter.createDisabledImage(img);
// print grayImage
Mahesh - 14 Feb 2006 10:42 GMT
This buffered image can be done on the xternal image files
like(jpeg,bmp) which we place inside the panel. But I need the entire
panel to be grayscaled.Consider a panel which is having only
Jcomponets!
zero - 14 Feb 2006 18:22 GMT
"Mahesh" <registered.here@gmail.com> wrote in news:1139913753.091108.215780
@g47g2000cwa.googlegroups.com:
> This buffered image can be done on the xternal image files
> like(jpeg,bmp) which we place inside the panel. But I need the entire
> panel to be grayscaled.Consider a panel which is having only
> Jcomponets!
That's why you use jPanel.paintComponent(bufferedImage.getGraphics());
This paints the jPanel, and everything in it, onto the image's graphics
object. This is exactly the same as painting it on the screen.