java - How to create an image from a JFrame with setVisible(false)? -
i created jframe creates grid calculation, , needed image , using:
public static bufferedimage createimagefromframe(component component) { int w = component.getwidth(); int h = component.getheight(); bufferedimage image = new bufferedimage(w,h,bufferedimage.type_int_rgb); component.paint( image.getgraphics() ); return image; }
calling like:
jframe window = new jframe(); // set stuff bufferedimage img = d.createimagefromframe(window.getcontentpane());
and fine. want create multiples images different frames, , don't want each 1 appear on screen, want images generated them. noticed cannot use setvisible(false)
cause gives java.lang.illegalargumentexception: width (0) , height (0) cannot <= 0
.
is there work around, or change may me accomplished that?
pack frame , move outside of visible area of display. example:
frame.pack(); frame.setlocation(-2000, -2000); frame.setvisible(true); // there go, frame won't visible
Comments
Post a Comment