public class JXEditorPane extends JEditorPane implements Targetable
JXEditorPane
offers enhanced functionality over the standard JEditorPane
. Unlike its parent, JXEdtiorPane
honors display properties
by default.
Users can revert to the behavior of JEditorPane
by setting the
property to false
.
JXEditorPane
provides HTML editing commands that alter functionality
depending on the document state. Currently, the user can quick-format the
document with headers (H# tags), paragraphs, and breaks.UndoableEditEvent
s. JXEditorPane
places those events in an UndoManager
and provides
undo/redo commands. Undo and redo are context-sensitive (like
the text commands) and will only be active if it is possible to perform the
command.JXEditorPane
provides search capabilities, allowing the user to find text
within the document.
Creating a JXEditorPane
is no different than creating a JEditorPane
. However, the following example demonstrates the best way to
access the improved command functionality.
JXEditorPane editorPane = new JXEditorPane("some URL"); add(editorPane); JToolBar toolBar = ActionContainerFactory.createToolBar(editorPane.getCommands[]); toolBar.addSeparator(); toolBar.add(editorPane.getParagraphSelector()); setToolBar(toolBar);
Modifier and Type | Class and Description |
---|---|
private class |
JXEditorPane.Actions
A small class which dispatches actions.
|
private class |
JXEditorPane.CaretHandler
Listens to the caret placement and adjusts the editing
properties as appropriate.
|
class |
JXEditorPane.DocumentSearchable
A
Searchable implementation for Document s. |
private class |
JXEditorPane.ParagraphSelector
A control which should be placed in the toolbar to enable
paragraph selection.
|
private class |
JXEditorPane.PropertyHandler |
private static class |
JXEditorPane.SloppyHTMLEditorKit
Handles sloppy HTML.
|
private class |
JXEditorPane.UndoHandler |
JEditorPane.AccessibleJEditorPane, JEditorPane.AccessibleJEditorPaneHTML, JEditorPane.JEditorPaneAccessibleHypertextSupport
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
private static String |
ACTION_COPY |
private static String |
ACTION_CUT |
private static String |
ACTION_FIND |
private static String |
ACTION_PASTE |
private static String |
ACTION_REDO |
private static String |
ACTION_UNDO |
private CaretListener |
caretHandler |
private static Logger |
LOG |
private Searchable |
searchable |
private JComboBox |
selector |
private TargetableSupport |
targetSupport |
private UndoableEditListener |
undoHandler |
private UndoManager |
undoManager |
HONOR_DISPLAY_PROPERTIES, W3C_LENGTH_UNITS
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
listenerList, 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 |
---|
JXEditorPane()
Creates a new
JXEditorPane . |
JXEditorPane(String url)
Creates a
JXEditorPane based on a string containing
a URL specification. |
JXEditorPane(String type,
String text)
Creates a
JXEditorPane that has been initialized
to the given text. |
JXEditorPane(URL initialPage)
Creates a
JXEditorPane based on a specified URL for input. |
Modifier and Type | Method and Description |
---|---|
protected void |
applyTag(HTML.Tag tag)
Applys the tag to the current selection
|
boolean |
doCommand(Object command,
Object value)
Perform the command using the object value.
|
private void |
find() |
(package private) CaretListener |
getCaretListener() |
Object[] |
getCommands()
Returns an array of supported commands.
|
JComboBox |
getParagraphSelector()
Retrieves a component which will be used as the paragraph selector.
|
int |
getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction) |
Searchable |
getSearchable() |
(package private) UndoableEditListener |
getUndoableEditListener() |
boolean |
hasCommand(Object command)
Return a flag that indicates if a command is supported.
|
private void |
init() |
protected void |
initActions()
Register the actions that this class can handle.
|
void |
paste()
The paste method has been overloaded to strip off the tags
This doesn't really work.
|
void |
setEditorKit(EditorKit kit)
Overidden to perform document initialization based on type.
|
void |
setSearchable(Searchable searchable)
sets the Searchable for this editor.
|
private void |
updateActionState()
Updates the state of the actions in response to an undo/redo operation.
|
addHyperlinkListener, createDefaultEditorKit, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getStream, getText, getUIClassID, paramString, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, replaceSelection, scrollToReference, setContentType, setEditorKitForContentType, setPage, setPage, setText
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDocument, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
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, 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, 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, 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, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
private UndoableEditListener undoHandler
private UndoManager undoManager
private CaretListener caretHandler
private static final String ACTION_FIND
private static final String ACTION_UNDO
private static final String ACTION_REDO
private static final String ACTION_CUT
private static final String ACTION_COPY
private static final String ACTION_PASTE
private TargetableSupport targetSupport
private Searchable searchable
public JXEditorPane()
JXEditorPane
.
The document model is set to null
.public JXEditorPane(String url) throws IOException
JXEditorPane
based on a string containing
a URL specification.url
- the URLIOException
- if the URL is null
or
cannot be accessedpublic JXEditorPane(String type, String text)
JXEditorPane
that has been initialized
to the given text. This is a convenience constructor that calls the
setContentType
and setText
methods.type
- mime type of the given texttext
- the text to initialize with; may be null
NullPointerException
- if the type
parameter
is null
public JXEditorPane(URL initialPage) throws IOException
JXEditorPane
based on a specified URL for input.initialPage
- the URLIOException
- if the URL is null
or cannot be accessedprivate void init()
CaretListener getCaretListener()
UndoableEditListener getUndoableEditListener()
public void setEditorKit(EditorKit kit)
setEditorKit
in class JEditorPane
protected void initActions()
private void updateActionState()
public JComboBox getParagraphSelector()
Note: This is only valid for the HTMLEditorKit
public void paste()
paste
in class JTextComponent
private void find()
public Searchable getSearchable()
public void setSearchable(Searchable searchable)
searchable
- public boolean hasCommand(Object command)
Targetable
hasCommand
in interface Targetable
command
- is a Action.ACTION_COMMAND_KEYpublic Object[] getCommands()
Targetable
getCommands
in interface Targetable
public boolean doCommand(Object command, Object value)
Targetable
doCommand
in interface Targetable
command
- is a Action.ACTION_COMMAND_KEYvalue
- an arbitrary value. Usually this will be
EventObject which trigered the command.public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface Scrollable
getScrollableUnitIncrement
in class JTextComponent
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses