jimmc.swing
Class HtmlPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JScrollPane
                          |
                          +--jimmc.swing.HtmlPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, javax.swing.event.HyperlinkListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.ScrollPaneConstants, java.io.Serializable

public class HtmlPanel
extends javax.swing.JScrollPane
implements javax.swing.event.HyperlinkListener

A panel to display HTML text.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JScrollPane
javax.swing.JScrollPane.AccessibleJScrollPane, javax.swing.JScrollPane.ScrollBar
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  java.lang.String currentUrl
          The location of the currently displayed page, or null if we are displaying an internal string.
protected  javax.swing.JEditorPane editor
          The editor panel.
protected  LimitedList history
          Our history.
protected  int historyPosition
          The index of the currently displayed item.
static int INITIAL_HISTORY_SIZE
          Initial history size.
protected  ResourceSource res
          Our resource source.
 
Fields inherited from class javax.swing.JScrollPane
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
 
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 javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
HtmlPanel(ResourceSource res)
          Create the Html panel.
 
Method Summary
 void addToHistory(java.lang.String item)
          Add an item to the history list.
 void fireHistoryChangeEvent()
          Here when the history changes.
 javax.swing.JComponent getPrintableComponent()
          Get the component to use for printing.
 java.lang.String getUrl()
          Get the location of the currently displayed page, or null if the page is internally generated (was set by a call to showHtml(java.lang.String)).
 boolean hasBack()
          True if a call to showBack will work.
 boolean hasForward()
          True if a call to showForward will work.
 void hyperlinkUpdate(javax.swing.event.HyperlinkEvent ev)
          Handle a hyperlink event.
 void setBackground(java.awt.Color color)
          Set the background color.
 boolean showBack()
          Back up the position by one and show the resulting item.
 boolean showForward()
          Move the position forward by one and show the resulting item.
 void showHtml(java.lang.String html)
          Show an html string.
 void showHtmlNoHistory(java.lang.String html)
          Show an html string, but don't add it to the history.
 void showUrl(java.lang.String url)
          Show the contents of a URL.
 void showUrlNoHistory(java.lang.String url)
          Show the contents of a URL, but don't add it to the history.
 
Methods inherited from class javax.swing.JScrollPane
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, paramString, setColumnHeader, setColumnHeaderView, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INITIAL_HISTORY_SIZE

public static final int INITIAL_HISTORY_SIZE
Initial history size.

res

protected ResourceSource res
Our resource source.

editor

protected javax.swing.JEditorPane editor
The editor panel.

history

protected LimitedList history
Our history.

historyPosition

protected int historyPosition
The index of the currently displayed item.

currentUrl

protected java.lang.String currentUrl
The location of the currently displayed page, or null if we are displaying an internal string.
Constructor Detail

HtmlPanel

public HtmlPanel(ResourceSource res)
Create the Html panel.
Method Detail

getPrintableComponent

public javax.swing.JComponent getPrintableComponent()
Get the component to use for printing.

setBackground

public void setBackground(java.awt.Color color)
Set the background color.
Overrides:
setBackground in class javax.swing.JComponent

getUrl

public java.lang.String getUrl()
Get the location of the currently displayed page, or null if the page is internally generated (was set by a call to showHtml(java.lang.String)).

showUrl

public void showUrl(java.lang.String url)
Show the contents of a URL.

showUrlNoHistory

public void showUrlNoHistory(java.lang.String url)
Show the contents of a URL, but don't add it to the history.

showHtml

public void showHtml(java.lang.String html)
Show an html string.

showHtmlNoHistory

public void showHtmlNoHistory(java.lang.String html)
Show an html string, but don't add it to the history.

addToHistory

public void addToHistory(java.lang.String item)
Add an item to the history list.

showBack

public boolean showBack()
Back up the position by one and show the resulting item.
Returns:
True if we were able to back up; false if we are already at the beginning of the list.

showForward

public boolean showForward()
Move the position forward by one and show the resulting item.
Returns:
True if we were able to go forward; false if we are already at the end of the list.

hasBack

public boolean hasBack()
True if a call to showBack will work.

hasForward

public boolean hasForward()
True if a call to showForward will work.

fireHistoryChangeEvent

public void fireHistoryChangeEvent()
Here when the history changes. Eventually, this method could have a listener list that it invokes, but for now we just let users subclass this class and override this method.

hyperlinkUpdate

public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent ev)
Handle a hyperlink event.
Specified by:
hyperlinkUpdate in interface javax.swing.event.HyperlinkListener