java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTree
org.bzdev.swing.ObjTocPane
org.bzdev.swing.UrlTocPane
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,Scrollable,TocTree,UrlTocTree
UrlTocPane provides a table of contents that associates each entry
in a table of contents with a URL.
An instance of the class can be initialized in the same way as an
instance of
ObjTocPane and in addition can be initialized
from an InputStream containing an XML file. When an XML
file is used, the following DTD should be used:
<!ELEMENT toc (node) >
<!ELEMENT node (node)*>
<!ATTLIST node title CDATA #IMPLIED
uri CDATA #IMPLIED
href CDATA #IMPLIED
>
A DOCTYPE directive is not necessary. For the attributes of each
node, the title attribute provides the title the GUI
will display. The uri attribute provides the URI,
which must also be a URL, that will be selected. The attribute
href is ignored. The href attribute is
provided for cases in which the XML file will used by a web server
and represents the URL that the web server will see after the XML
file is converted to HTML (e.g., by an XSTL style sheet). This
class ignores the href field. One may wish to call
the method ObjTocPane.setSelectionWithAction(int) in order
to set an initial selection and to notify any previously configured
action listeners of the selection. The documentation for the class
ObjTocPane contains details regarding action events.
To configure a table of contents programatically, use the method
addEntry(String,URL) or
addEntry(String,String) and related methods
defined in the class ObjTocPane. To replace the entries
with a new set, use one of the setToc methods or call
ObjTocPane.clearToc() and then programatically add the new
entries. The method ObjTocPane.setSelectionWithAction(int)
calls ObjTocPane.clearToc() so an explicit call is not
necessary in this case.
Finally the method Handlers.enable()
should be called before this class is used so that the DTD can be
read from a JAR file.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bzdev.swing.ObjTocPane
ObjTocPane.EntryNested classes/interfaces inherited from class javax.swing.JTree
JTree.AccessibleJTree, JTree.DropLocation, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirectorNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
Fields inherited from class javax.swing.JTree
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, editable, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, invokesStopCellEditing, LARGE_MODEL_PROPERTY, largeModel, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, rootVisible, ROW_HEIGHT_PROPERTY, rowHeight, SCROLLS_ON_EXPAND_PROPERTY, scrollsOnExpand, SELECTION_MODEL_PROPERTY, selectionModel, selectionRedirector, SHOWS_ROOT_HANDLES_PROPERTY, showsRootHandles, TOGGLE_CLICK_COUNT_PROPERTY, toggleClickCount, TREE_MODEL_PROPERTY, treeModel, treeModelListener, VISIBLE_ROW_COUNT_PROPERTY, visibleRowCountFields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionClass Constructor.UrlTocPane(URL url) Class Constructor specifying an input stream for initialization.UrlTocPane(URL url, boolean expand) Class Constructor specifying an input stream for initialization and a flag indicating if the nodes should be expanded or not.UrlTocPane(URL url, boolean expand, boolean validating) Constructor for UrlTocPane. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an entry.voidAdd an entry.voidsetToc(InputStream is, boolean expand, boolean validating) Set the Table of Contents from an input stream.voidSet the Table of Contents from a string providing a URL.voidSet the Table of Contents from a URL.Methods inherited from class org.bzdev.swing.ObjTocPane
addActionListener, addEntry, clearSelection, clearToc, entriesCompleted, entriesCompleted, fireActionPerformed, nextLevel, prevLevel, removeActionListener, setBackground, setCellRenderer, setForeground, setSelectionWithAction, setTCRBackgroundNonSelectionColor, setTCRBackgroundSelectionColor, setTCRFont, setTCRTextNonSelectionColor, setTCRTextSelectionColorMethods inherited from class javax.swing.JTree
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearToggledPaths, collapsePath, collapseRow, convertValueToText, createTreeModel, createTreeModelListener, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, fireValueChanged, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDefaultTreeModel, getDescendantToggledPaths, getDragEnabled, getDropLocation, getDropMode, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, getNextMatch, getPathBetweenRows, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getToolTipText, getTreeExpansionListeners, getTreeSelectionListeners, getTreeWillExpandListeners, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isEditing, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isSelectionEmpty, isVisible, makeVisible, paramString, removeDescendantSelectedPaths, removeDescendantToggledPaths, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellEditor, setDragEnabled, setDropMode, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setModel, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, startEditingAtPath, stopEditing, treeDidChange, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bzdev.swing.TocTree
addActionListener, addEntry, clearSelection, clearToc, collapseRow, entriesCompleted, entriesCompleted, expandRow, isCollapsed, isExpanded, nextLevel, prevLevel, removeActionListener, setSelectionWithAction
-
Constructor Details
-
UrlTocPane
public UrlTocPane()Class Constructor. -
UrlTocPane
public UrlTocPane(URL url) throws FactoryConfigurationError, SAXException, IOException, ParserConfigurationException Class Constructor specifying an input stream for initialization. The input stream contains an XML document.- Parameters:
url- The URL for the page- Throws:
FactoryConfigurationError- the XML parser cannot be configuredSAXException- the XML data in the input stream in not well formed or is not valid.IOException- an IO error was seenParserConfigurationException- the XML parser cannot be configured
-
UrlTocPane
public UrlTocPane(URL url, boolean expand) throws FactoryConfigurationError, SAXException, IOException, ParserConfigurationException Class Constructor specifying an input stream for initialization and a flag indicating if the nodes should be expanded or not. The input stream contains an XML document.- Parameters:
url- The URL for the pageexpand- True if the nodes should be expanded; false otherwise- Throws:
FactoryConfigurationError- the XML parser cannot be configuredSAXException- the XML data in the input stream in not well formed or is not valid.IOException- an IO error was seenParserConfigurationException- the XML parser cannot be configured
-
UrlTocPane
public UrlTocPane(URL url, boolean expand, boolean validating) throws FactoryConfigurationError, SAXException, IOException, ParserConfigurationException Constructor for UrlTocPane. The input stream contains an XML document.- Parameters:
url- The URL for the pageexpand- True if the nodes should be expanded; false otherwisevalidating- True if the parser is validating; false otherwise- Throws:
FactoryConfigurationError- the XML parser cannot be configuredSAXException- the XML data in the input stream in not well formed or is not valid.IOException- an IO error was seenParserConfigurationException- the XML parser cannot be configured
-
-
Method Details
-
addEntry
Add an entry. This will define a new node in the tree.- Specified by:
addEntryin interfaceUrlTocTree- Parameters:
title- A string naming the entry.url- The URL to associate with the entry;- Throws:
IllegalStateException- if this method was called after a call toentriesCompleted.MalformedURLException- if the url is malformed- See Also:
-
addEntry
Add an entry. This will define a new node in the tree.- Specified by:
addEntryin interfaceUrlTocTree- Parameters:
title- A string naming the entry.url- The URL to associate with the entry;- Throws:
IllegalStateException- if this method was called after a call toentriesCompleted.- See Also:
-
setToc
public void setToc(String url, boolean expand, boolean validating) throws FactoryConfigurationError, SAXException, IOException, ParserConfigurationException, MalformedURLException Set the Table of Contents from a string providing a URL.- Specified by:
setTocin interfaceUrlTocTree- Parameters:
url- The URL for the pageexpand- True if the nodes should be expanded; false otherwisevalidating- True if the parser is validating; false otherwise- Throws:
FactoryConfigurationError- the XML parser cannot be configuredSAXException- the XML data in the input stream in not well formed or is not valid.IOException- an IO error was seenParserConfigurationException- the XML parser cannot be configuredMalformedURLException- the URL argument has a syntax error
-
setToc
public void setToc(URL url, boolean expand, boolean validating) throws FactoryConfigurationError, SAXException, IOException, ParserConfigurationException Set the Table of Contents from a URL.- Specified by:
setTocin interfaceUrlTocTree- Parameters:
url- The URL for the pageexpand- True if the nodes should be expanded; false otherwisevalidating- True if the parser is validating; false otherwise- Throws:
FactoryConfigurationError- the XML parser cannot be configuredSAXException- the XML data in the input stream in not well formed or is not valid.IOException- an IO error was seenParserConfigurationException- the XML parser cannot be configured
-
setToc
public void setToc(InputStream is, boolean expand, boolean validating) throws FactoryConfigurationError, SAXException, IOException, ParserConfigurationException Set the Table of Contents from an input stream.- Specified by:
setTocin interfaceUrlTocTree- Parameters:
is- the Inputstream containing the table of contents.expand- True if the nodes should be expanded; false otherwisevalidating- True if the parser is validating; false otherwise- Throws:
FactoryConfigurationError- the XML parser cannot be configuredSAXException- the XML data in the input stream in not well formed or is not valid.IOException- an IO error was seenMalformedURLException- the string representing the URL was illformed.ParserConfigurationException- the XML parser cannot be configured
-