public class HTMLViewer extends JPanel implements GenericToolBarTarget
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected AbstractAction |
backAction
Action to use for the "Back" menu and toolbar items
|
protected Stack |
backStack
Stack of HTMLViewerHistoryItem, used to go back to a previous page
|
protected static JFileChooser |
fileChooser
Reuse file chooser widget
|
protected AbstractAction |
forwAction
Action to use for the "Forward" menu and toolbar items
|
protected Stack |
forwStack
Stack of HTMLViewerHistoryItem, used to go forward to the next page
|
protected static String |
HISTORY_LIST_NAME
Base filename for serialization of the history list
|
protected LinkedList |
historyList
List of HTMLViewerHistoryItem, for previously viewed catalogs or query results.
|
protected JEditorPane |
html
Used to display HTML
|
protected EventListenerList |
listenerList
list of listeners for change events
|
protected int |
maxHistoryItems
Max number of items in the history list
|
protected boolean |
noStack
Set when the back or forward actions are active to avoid the normal history stack handling
|
protected AbstractAction |
openAction
Action to use for the "Open..." menu and toolbar items
|
protected Component |
parent
The top level parent frame (or internal frame) used to close the window
|
protected AbstractAction |
printAction
Action to use for the "Print..." menu and toolbar items
|
protected AbstractAction |
saveAsAction
Action to use for the "Save as..." menu and toolbar items
|
protected URL |
url
The URL of the currently displayed page
|
TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
HTMLViewer()
Create a window for displaying HTML.
|
HTMLViewer(Component parent)
Create a window for displaying HTML.
|
HTMLViewer(Component parent,
URL url)
Create a window for displaying the given HTML URL.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ChangeListener l)
Register to receive change events from this object whenever a new
HTML page is displayed.
|
void |
addHistoryMenuItems(JMenu menu)
Add history items (for previously displayed components) to the given menu
|
protected void |
addToHistory()
Add the current URL to the history stack, removing duplicates.
|
protected void |
addToHistory(HTMLViewerHistoryItem historyItem)
Add the given item to the history stack, removing duplicates.
|
void |
back()
Go back to the previous component in the history list
|
protected void |
cleanupHistoryList()
This method is called after the history list is deserialized to remove any
items in the list that can't be accessed.
|
protected void |
clearHistory()
Add the current URL to the history list
|
void |
close()
Close the window
|
protected HyperlinkListener |
createHyperLinkListener()
Create and return a listener for HTML links.
|
protected void |
fireChange(ChangeEvent e)
Notify any listeners that a new HTML page is being displayed.
|
void |
forward()
Go forward to the next component in the history list
|
AbstractAction |
getBackAction()
Return the action for "Back"
|
JEditorPane |
getEditorPane()
Used to display HTML
|
AbstractAction |
getForwAction()
Return the action for "Forward"
|
int |
getMaxHistoryItems()
Return the max number of items in the history list.
|
AbstractAction |
getOpenAction()
Return the action for "Open"
|
AbstractAction |
getPrintAction() |
AbstractAction |
getSaveAsAction() |
protected void |
loadHistory()
Try to load the history list from a file, and create an empty list if that fails.
|
protected JFileChooser |
makeFileChooser()
Create and return a new file chooser to be used to select a file to open.
|
protected HTMLViewerHistoryItem |
makeHTMLViewerHistoryItem()
Return a new HTMLViewerHistoryItem for the currently displayed catalog.
|
protected LinkedList |
mergeHistoryList()
Merge the historyList with current serialized version (another instance
may have written it since we read it last).
|
void |
open()
Display a file chooser to select a local catalog file to open
|
void |
open(String fileOrUrl)
Open and display the given file or URL
|
void |
openURL()
Display a dialog to enter a URL to display
|
void |
print()
Pop up a dialog for printing the current page.
|
void |
removeChangeListener(ChangeListener l)
Stop receiving change events from this object.
|
void |
saveAs()
Pop up a dialog to ask the user for a file name, and then save the current page
to the selected file.
|
protected void |
saveHistory(boolean merge)
Save the current history list to a file.
|
void |
setMaxHistoryItems(int n)
Set the max number of items in the history list.
|
void |
setPage(URL url)
Display the given URL, which should have the content type text/html.
|
void |
setText(String text)
Display the given HTML text.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
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, validateTree
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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected Component parent
protected JEditorPane html
protected URL url
protected static JFileChooser fileChooser
protected EventListenerList listenerList
protected Stack backStack
protected Stack forwStack
protected boolean noStack
protected LinkedList historyList
protected static final String HISTORY_LIST_NAME
protected int maxHistoryItems
protected AbstractAction openAction
protected AbstractAction backAction
protected AbstractAction forwAction
protected AbstractAction saveAsAction
protected AbstractAction printAction
public HTMLViewer()
public HTMLViewer(Component parent)
parent
- the top level parent frame (or internal frame) used to close the windowpublic JEditorPane getEditorPane()
public void setPage(URL url)
url
- A URL to displaypublic void setText(String text)
protected HyperlinkListener createHyperLinkListener()
public void open()
protected JFileChooser makeFileChooser()
public void open(String fileOrUrl)
public void openURL()
public void close()
public void back()
public void forward()
public void addChangeListener(ChangeListener l)
public void removeChangeListener(ChangeListener l)
protected void fireChange(ChangeEvent e)
protected void addToHistory()
protected void addToHistory(HTMLViewerHistoryItem historyItem)
protected HTMLViewerHistoryItem makeHTMLViewerHistoryItem()
public int getMaxHistoryItems()
public void setMaxHistoryItems(int n)
public void addHistoryMenuItems(JMenu menu)
protected void cleanupHistoryList()
protected LinkedList mergeHistoryList()
protected void clearHistory()
protected void saveHistory(boolean merge)
merge
- if true, merge the list with the existing list on disk.protected void loadHistory()
public void saveAs()
public void print()
public AbstractAction getOpenAction()
GenericToolBarTarget
getOpenAction
in interface GenericToolBarTarget
public AbstractAction getSaveAsAction()
public AbstractAction getPrintAction()
public AbstractAction getBackAction()
GenericToolBarTarget
getBackAction
in interface GenericToolBarTarget
public AbstractAction getForwAction()
GenericToolBarTarget
getForwAction
in interface GenericToolBarTarget
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.