java - How to save a scrollable JPanel as a jpeg image (not as a snapshot) -


how possible store jpanel jpeg image solutions search takes snapshot of display, not capture contents of jpanel part of hidden. there way of getting entire image in jpeg.

this solution available here not working fine @ solution

code using take snapshot of jpanel

if (panelx == null) { jbutton3.settext("generate diagram"); } else { jbutton3.settext("generate diagram"); jtextpane1 .settext(messages.getstring("statement2")); //$non-nls-1$ jframe win = (jframe) swingutilities .getwindowancestor(panelx.panelx); dimension size = win.getsize(); // bufferedimage image = new bufferedimage(size.width, size.height, // bufferedimage.type_int_rgb); bufferedimage image = (bufferedimage) win.createimage(size.width, size.height); graphics g = image.getgraphics(); win.paint(g); g.dispose(); try { imageio.write( image, messages.getstring("statement38"), new file(messages.getstring("statement5"))); //$non-nls-1$ //$non-nls-2$ } catch (ioexception e) { system.out.println("image cannot created"); } 

you don't explain why example doesn't work.

why using window not panel? if using example answer should refer panel within scrollpane.

you're calling paint on whole jframe rather panel interested in.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -