Possible Duplicate:
Using Swing with a framebuffer
I’ve been searching all day for solutions in various directions to my problem. I’m working on Java running on the Kobo Touch, and I’d like to use Swing to render the components. The problem is, if I simply call paint() or its friends, the component in question will only render itself. If I use a JFrame to pack() the components, then it works on the desktop, but when I move it to the Kobo it fails because the Java environment is headless there.
In a headless environment, what is the simplest way to render a JPanel with children into a BufferedImage or Graphics2D?
Check this out:
Can I create a BufferedImage from a JPanel without rendering in a JFrame?
BTW, why is it headless? Kobo Touch does have a display…
EDIT: As the original poster found out,
is one way to force the layout manager to lay out the children if no frame is used, and therefore frame.pack() does not trigger the layout managers.