|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JEditorPane
net.sourceforge.sillyview.HTMLPane
public class HTMLPane
This class is a convenience class for JEditorPanes used to show HTML content that are un-editable (so as to enable listening for hyperlink events) and handle UTF-8 characters gracefully. It wouldn't be strictly necessary were it not for some bugs in the Java 1.4.2 StyledDocument api (getlength()=0). This class keeps its own copy of the EditorPane's text to work around the getLength, and subsequent getText problems. Important to note is that a HTMLPane is aware of and responsive to Swing Pluggable LookAndFeel colors. JEditorPanes are ignorant of changes to LookAndFeel. You can plug in your own LookAndFeel to StyleSheet converter by subclassing LookAndFeelToCSS and using HTMLPane's setConverter() method. The default BasicLookAndFeelToCSS converter may well not handle your favorite LookAndFeel (Swing's default Metal LookAndFeel is supported) , and you may be forced to write a LookAndFeelToCSS converter for it. A "theme" stylesheet (the result of a conversion) does not override styles implemented directly in the HTML document or included in the HTML document. It does override all other styles.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JEditorPane |
|---|
JEditorPane.AccessibleJEditorPane, JEditorPane.AccessibleJEditorPaneHTML, JEditorPane.JEditorPaneAccessibleHypertextSupport |
| Nested classes/interfaces inherited from class javax.swing.text.JTextComponent |
|---|
JTextComponent.AccessibleJTextComponent, JTextComponent.KeyBinding |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class javax.swing.text.JTextComponent |
|---|
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
HTMLPane()
Creates a new HTMLPane instance with no text. |
|
HTMLPane(String text)
Creates a new HTMLPane instance with the given text. |
|
HTMLPane(String text,
StyleSheet theme)
Creates a new HTMLPane instance with the given
text and stylesheet. |
|
HTMLPane(StyleSheet theme)
Creates a new HTMLPane instance with the given
stylesheet. |
|
HTMLPane(URL initialPage)
Creates a new HTMLPane instance showing the HTML
page at the given URL and with no accessory stylesheet. |
|
HTMLPane(URL initialPage,
StyleSheet theme)
Creates a new HTMLPane instance showing the HTML page
at the given URL and with the given accesory stylesheet. |
|
| Method Summary | |
|---|---|
void |
addHyperlinkListener(HyperlinkListener listener)
Add a HyperlinkListener to this pane. |
void |
doLayout()
Tries to do super.doLayout() and warns if this causes an exception. |
void |
dump()
Dumps the current stylesheet for debugging. |
void |
dump(StyleSheet styles)
Sends all style rules to be printed out to System.out. |
void |
forceValidate()
|
LookAndFeelToCSS |
getConverter()
Describe getConverter method here. |
protected static String |
getDocument(URL u)
Returns the HTML document at the given URL as a String. |
protected StyleSheet |
getDocumentStyleSheet()
Returns the stylesheet for the current document. |
void |
setAutoDump(boolean newAutoDump)
Setting autoDump to true causes the stylesheet to be printed every time it is changed. |
void |
setConverter(LookAndFeelToCSS conv)
Allows you to plug in a LookAndFeel to CSS converter of your choice. |
void |
setText(String text)
Sets the text and clears and clears any applied "theme" stylesheets. |
protected void |
setTheme(String styleSheetUrl)
Adds the stylesheet at the given url as a "theme," i.e. |
void |
setUI(TextUI newui)
Describe setUI method here. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public HTMLPane()
HTMLPane instance with no text.
public HTMLPane(String text)
HTMLPane instance with the given text.
Default text encoding is "text/html; UTF-8".
text - a String valuepublic HTMLPane(StyleSheet theme)
HTMLPane instance with the given
stylesheet. Default text encoding is "text/html; UTF-8".
theme - a StyleSheet value
public HTMLPane(String text,
StyleSheet theme)
HTMLPane instance with the given
text and stylesheet. Default text encoding is "text/html; UTF-8".
text - a String valuetheme - a StyleSheet value
public HTMLPane(URL initialPage)
throws IOException
HTMLPane instance showing the HTML
page at the given URL and with no accessory stylesheet.
Default text encoding is "text/html; UTF-8".
initialPage - an URL value
IOException - if an error occurs
public HTMLPane(URL initialPage,
StyleSheet theme)
throws IOException
HTMLPane instance showing the HTML page
at the given URL and with the given accesory stylesheet.
Default text encoding is "text/html; UTF-8".
initialPage - an URL valuetheme - a StyleSheet value
IOException - if an error occurs| Method Detail |
|---|
protected StyleSheet getDocumentStyleSheet()
StyleSheet value
protected static String getDocument(URL u)
throws IOException
u - an URL value
String value
IOException - if an error occurs
protected void setTheme(String styleSheetUrl)
throws MalformedURLException
styleSheetUrl - a String value
MalformedURLException - if an error occurspublic final void setText(String text)
setText in class JEditorPanetext - a String valuepublic final void dump()
public void setAutoDump(boolean newAutoDump)
b - a boolean valuepublic final void dump(StyleSheet styles)
styles - a StyleSheet valuepublic void setUI(TextUI newui)
setUI method here.
setUI in class JTextComponentnewui - a javax.swing.plaf.TextUI valuepublic final LookAndFeelToCSS getConverter()
getConverter method here.
LookAndFeelToCSS valuepublic final void setConverter(LookAndFeelToCSS conv)
conv - a LookAndFeelToCSS valuepublic void addHyperlinkListener(HyperlinkListener listener)
addHyperlinkListener in class JEditorPanel - a HyperlinkListener valuepublic void doLayout()
doLayout in class Containerpublic void forceValidate()
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||