public class BDocumentViewer extends Widget
When the user clicks on a hyperlink inside an HTML document, the BDocumentViewer generates a
DocumentLinkEvent
. You can then pass that event to
processLinkEvent()
, which will load the
new document pointed to by the hyperlink. This can be done most easily by having the BDocumentViewer
listen for its own events directly:
viewer.addEventLink(DocumentLinkEvent.class, viewer, "processLinkEvent");
Alternatively, you can have another object listen for the events and then pass them on to the BDocumentViewer. This would be useful, for example, if you wanted to filter the events and only allow certain hyperlinks to be followed.
When you tell the BDocumentViewer to load a new document, either by calling
setDocument()
or
processLinkEvent()
, the loading is usually
done asynchronously. When loading is complete, it generates a
ValueChangedEvent
. If you want to show a
progress bar while the document is being loaded, for example, you can listen for the event to
know when to stop animating the progress bar.
In addition to the event types generated by all Widgets, BDocumentViewers generate the following event types:
Constructor and Description |
---|
BDocumentViewer()
Create an empty BDocumentViewer.
|
BDocumentViewer(java.net.URL document)
Create a new BDocumentViewer displaying the document referenced by a URL.
|
Modifier and Type | Method and Description |
---|---|
javax.swing.JEditorPane |
getComponent()
Get the java.awt.Component corresponding to this Widget.
|
java.lang.String |
getContentType()
Get the MIME type of the document currently being displayed.
|
java.net.URL |
getDocument()
Get the URL for the document currently being displayed.
|
void |
processLinkEvent(DocumentLinkEvent event)
Process a DocumentLinkEvent generated by this viewer, and handle it appropriately.
|
void |
setDocument(java.lang.String text,
java.lang.String type)
Set the document to display in this BDocumentViewer.
|
void |
setDocument(java.net.URL document)
Set the document to display in this BDocumentViewer.
|
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible
addEventLink, addEventLink, removeEventLink
public BDocumentViewer()
public BDocumentViewer(java.net.URL document) throws java.io.IOException
document
- a URL pointing to the document to displayjava.io.IOException
public javax.swing.JEditorPane getComponent()
Widget
getComponent
in class Widget
public java.net.URL getDocument()
public void setDocument(java.net.URL document) throws java.io.IOException
document
- a URL pointing to the document to displayjava.io.IOException
public void setDocument(java.lang.String text, java.lang.String type)
text
- the text of the document to displaytype
- the MIME type of the documentpublic java.lang.String getContentType()
public void processLinkEvent(DocumentLinkEvent event) throws java.io.IOException
java.io.IOException
Written by Peter Eastman.