// information, the render engine would lay out the runs of text to as wide a space as needed to
// accomodate the text without breaks.
panel.setSize(10000, 10000);
// now we lay the document out again
panel.doDocumentLayout(panel.getGraphics());
// and reset the size
panel.setSize(savedSize);
f.pack();