com.quadrique.jbuildingblocks.gui
Class TextPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JEditorPane
                      extended by javax.swing.JTextPane
                          extended by com.quadrique.jbuildingblocks.gui.TextPane
All Implemented Interfaces:
MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, Scrollable

public class TextPane
extends JTextPane
implements MouseListener

A convenience class to simplify the usage of the JTextPane component The JTextPane is encapsulated in a specialized JPanel

Author:
Hervé Rivere
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JEditorPane
HONOR_DISPLAY_PROPERTIES, W3C_LENGTH_UNITS
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
TextPane()
          constructor
 
Method Summary
 MenuPopup getPopupMenu()
           
 int getPositionOfComponent(Object zObj)
           
 void insertComponentAtTheEnd(JComponent zComponent)
          to insert a JComponent (e.g.
 void insertTextAtTheEnd(String zText, TextPaneAttributeSet zSet)
          to insert text at the end of the document
 void mouseClicked(MouseEvent e)
          The mouse listener interface
 void mouseEntered(MouseEvent e)
          The mouse listener interface
 void mouseExited(MouseEvent e)
          The mouse listener interface
 void mousePressed(MouseEvent e)
          The mouse listener interface
 void mouseReleased(MouseEvent e)
          The mouse listener interface
 ArrayList<TextPaneSegment> parseToSegments()
          parse the current document in segments segments are either text or a component the beginning/end of a segment is indicated by the transition from text to component and vice-versa
 void removeComponent(JComponent zComponent)
          to remove a component from the pane
 void setSelectionToCaret()
          to set the current selection to be the caret position.
 void setSelectionToEnd()
          to set the current selection to be the end of the document
 void setUserData(int zStartPos, int zEndPos, Object zUserData)
          set the given user data object to each character in the given range
 void setUserDataToSelection(Object zObj)
          set the given user data object to the current selection
 
Methods inherited from class javax.swing.JTextPane
addStyle, getCharacterAttributes, getInputAttributes, getLogicalStyle, getParagraphAttributes, getStyle, getStyledDocument, getUIClassID, insertComponent, insertIcon, removeStyle, replaceSelection, setCharacterAttributes, setDocument, setEditorKit, setLogicalStyle, setParagraphAttributes, setStyledDocument
 
Methods inherited from class javax.swing.JEditorPane
addHyperlinkListener, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getText, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, scrollToReference, setContentType, setEditorKitForContentType, setPage, setPage, setText
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, read, removeCaretListener, removeKeymap, removeNotify, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, hide, 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, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextPane

public TextPane()
         throws Exception
constructor

Throws:
Exception - if an error occurs
Method Detail

setSelectionToCaret

public void setSelectionToCaret()
to set the current selection to be the caret position. If there is no caret yet, the selection is set to the end of the document


setSelectionToEnd

public void setSelectionToEnd()
to set the current selection to be the end of the document


insertComponentAtTheEnd

public void insertComponentAtTheEnd(JComponent zComponent)
                             throws Exception
to insert a JComponent (e.g. a JButton) the end of the document

Parameters:
zComponent - the compoennt to insert
Throws:
Exception - if an error occurs

insertTextAtTheEnd

public void insertTextAtTheEnd(String zText,
                               TextPaneAttributeSet zSet)
                        throws Exception
to insert text at the end of the document

Parameters:
zText - the text to insert
zSet - the attribute set for the given text
Throws:
Exception - if an error occurs

setUserData

public void setUserData(int zStartPos,
                        int zEndPos,
                        Object zUserData)
                 throws Exception
set the given user data object to each character in the given range

Parameters:
zStartPos - position from the beginning of the document (0-based)
zEndPos - position form the baginning of the docuemnt (0-based). Please
zUserData - the user data object note that the character at the position zEndPos is not included
Throws:
Exception

setUserDataToSelection

public void setUserDataToSelection(Object zObj)
                            throws Exception
set the given user data object to the current selection

Parameters:
zObj - the user data object
Throws:
Exception

removeComponent

public void removeComponent(JComponent zComponent)
                     throws Exception
to remove a component from the pane

Parameters:
zComponent - the component to remove
Throws:
Exception - if an error occur (including the case were the component is not found)

parseToSegments

public ArrayList<TextPaneSegment> parseToSegments()
                                           throws Exception
parse the current document in segments segments are either text or a component the beginning/end of a segment is indicated by the transition from text to component and vice-versa

Returns:
an ArrayList which contains the list of TextPaneSegment corresponding to the segments
Throws:
Exception

getPopupMenu

public MenuPopup getPopupMenu()
Returns:
the PopupMenu instance that is used by this TextPane

getPositionOfComponent

public int getPositionOfComponent(Object zObj)
                           throws Exception
Returns:
the position of the given component or -1 if the component was not found
Throws:
Exception

mouseReleased

public void mouseReleased(MouseEvent e)
The mouse listener interface

Specified by:
mouseReleased in interface MouseListener
Parameters:
e - the mouse event
See Also:
MouseListener

mouseClicked

public void mouseClicked(MouseEvent e)
The mouse listener interface

Specified by:
mouseClicked in interface MouseListener
Parameters:
e - the mouse event
See Also:
MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
The mouse listener interface

Specified by:
mouseEntered in interface MouseListener
Parameters:
e - the mouse event
See Also:
MouseListener

mouseExited

public void mouseExited(MouseEvent e)
The mouse listener interface

Specified by:
mouseExited in interface MouseListener
Parameters:
e - the mouse event
See Also:
MouseListener

mousePressed

public void mousePressed(MouseEvent e)
The mouse listener interface

Specified by:
mousePressed in interface MouseListener
Parameters:
e - the mouse event
See Also:
MouseListener


Copyright © 2001-2009 Quadrique Corporation. All Rights Reserved.