SSISO Community

시소당

java JEditPane 화면 이미지로 저장하기

save  the  output  from  a  JEditorPane  as  a  GIF  or  PNG  or  other
graphic  image.  


public  void  writeSnapshot(JEditorPane  editor,  OutputStream  out)
        throws  ...
{
        int  width  =  editor.getWidth();
        int  height  =  editor.getHeight();

        Image  offscreen  =  new  BufferedImage(
                width,  height,  BufferedImage.TYPE_INT_RGB);

        Graphics  g  =  offscreen.getGraphics();
        try
        {
                editor.paint(g);
        }
        finally
        {
                g.dispose();
        }

        ImageIO.write(img,  "png",  out);
}

  This  is  assuming  that  you're  using  JDK  1.4,  so  you  can  use  ImageIO.    If
not,  there  are  a  few  third-party  libraries  floating  around  to  do  image
encoding.
------------------------------------------------------------------------------

  

우연히  찾게  된  정보  JEditPane을  화면으로  저장할  수  있다니  나중에  한번  해봐야겠다.

[출처]  java  JEditPane  화면  이미지로  저장하기|작성자  처리
출처  :  http://blog.naver.com/ace772?Redirect=Log&logNo=120001592493

640 view

4.0 stars