|
FAQSwing
Frequently-asked questions about rendering in Swing panels
Featured Swing Related Questions
How do I make my program follow hyperlinks?You need a mouse listener that detects link clicks and does the HTTP request. The BasicPanel supports tracking mouse events and delegating them to FSMouseListener instances. You can use the org.xhtmlrenderer.swing.LinkListener class, which implements FSMouseListener, for basic hyperlink navigation support. How do I get access to the Swing components that make up my form fields?Take a look at the org.xhtmlrenderer.simple.extend.XhtmlForm class. Form elements are "replaced" at runtime by the org.xhtmlrenderer.swing.SwingReplacedElementFactory if you're using the XHTMLPanel class for rendering. The factory actually creates a new XhtmlForm class which creates and tracks the components. To receive a callback when the user submits a form, add a FormSubmissionListener instance to your BasicPanel. How do I get the starting index of selected text?I am using the selection / highlighting capabilities in Flying Saucer. Hightlighting works fine, but I need to have the index of the selection. Is this possible? That's not possible out of the box. The DOM interface doesn't provide position information. An option is to walk through the nodes of the document to the left of the start of the selected range and then adding all the text content lengths. The Size of the Rendered DocumentHow do I figure out the size of a document I'm rendering? Can I get this from the renderer? How about preferred size of XHTMLPanel? Why isn't my panel properly sized on screen? The rules are that the document size is calculated after a layout takes place; for rendering to a Swing panel, this can only happen if the container for the panel (e.g. the window) is displayable. See this email thread in our mailing list for a discussion. In our demos/samples directory in the source distribution, the PanelResizeToPreferredSize and JPanelSizeToDocument show how this is done. Basically (quoting from the mail thread): So basically you want to:
it has been layed out. The second call to pack() after doDocumentLayout() takes care of doing this. See PanelResizeToPreferredSize for an example using FlowLayout.
|