public class JTextComponentRowHeader extends JPanel
JScrollPane showing the line numbers of
JTextComponent.
The text lines in JTextComponent must be fixed height.JPanel.AccessibleJPanelJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
protected Color |
borderColor
The color of the border that joint the gutter and the script text area.
|
protected int |
borderWidth
The width of the border that joint the gutter and the script text area.
|
protected Document |
document
The document of the text component.
|
protected DocumentListener |
documentListener
The document listener for
document. |
protected Color |
highlightedColor
The background of the row when it is highlighted.
|
protected List<Integer> |
highlightedLineList
The list of line numbers that indicate which lines are needed to be
highlighted.
|
protected int |
largestRowNumber
The cached largest row number (for determine panel width
panelWidth). |
protected int |
lineNumberOffset
The line number offset.
|
protected boolean |
listenToDocumentUpdate
Indicator indicate whether it is listening to the document change events
or not.
|
protected int |
paddingLeft
The minimum padding from 'the leftmost of the line number text' to
'the left margin'.
|
protected int |
paddingRight
The minimum padding from 'the rightmost of the line number text' to
'the right margin' (not to the gutter border).
|
protected int |
panelWidth
The cached panel width.
|
protected JScrollPane |
scrollPane
The JScrollPane that it be added into.
|
protected Object |
textAntiAliasing
The anti-aliasing setting of the line number text.
|
protected JTextComponent |
textComponent
The text component to listen the change events on.
|
protected int |
textComponentHeight
The cached text component height, for determine panel height.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
JTextComponentRowHeader(JScrollPane scrollPane,
JTextComponent textComponent)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addHighlightedLine(int lineNumber)
Add highlighted line.
|
void |
checkPanelSize()
Check whether the height of the row header panel match with the height of
the text component or not.
|
void |
clearHighlightedLine()
Clear highlighted lines.
|
Color |
getBorderColor()
The color of the border that joint the gutter and the script text area.
|
int |
getBorderWidth()
The width of the border that joint the gutter and the script text area.
|
Color |
getHighlightedColor()
The background of the highlighted row.
|
List<Integer> |
getHighlightedLineList()
Get the list of highlighted lines.
|
int |
getLineNumberOffset()
Get the line number offset
|
int |
getPaddingLeft()
The minimum padding from the 'leftmost of the line number text' to the
'left margin'.
|
int |
getPaddingRight()
The minimum padding from the 'rightmost of the line number text' to the
'right margin' (not to the gutter border).
|
Dimension |
getPreferredSize() |
Object |
getTextAntiAliasing()
The anti-aliasing setting of the line number text.
|
boolean |
isListenToDocumentUpdate()
Check if it is listening to the document change events.
|
void |
paint(Graphics g) |
void |
setBackground(Color background)
The background of the panel.
|
void |
setBorderColor(Color borderColor)
The color of the border that joint the gutter and the script text area.
|
void |
setBorderWidth(int borderWidth)
The width of the border that joint the gutter and the script text area.
|
void |
setFont(Font font)
The font of the line number.
|
void |
setForeground(Color foreground)
The color of the line number.
|
void |
setHighlightedColor(Color highlightedColor)
The background of the highlighted row.
|
void |
setHighlightedLineList(List<Integer> highlightedLineList)
Set highlighted lines.
|
void |
setLineNumberOffset(int offset)
Set the line number offset.
|
void |
setListenToDocumentUpdate(boolean listenToDocumentUpdate)
Set to listen to document change events or not.
|
void |
setPaddingLeft(int paddingLeft)
The minimum padding from 'the leftmost of the line number text' to the
'left margin'.
|
void |
setPaddingRight(int paddingRight)
The minimum padding from the 'rightmost of the line number text' to the
'right margin' (not to the gutter border).
|
void |
setTextAntiAliasing(Object textAntiAliasing)
The anti-aliasing setting of the line number text.
|
protected void |
updatePanelSize()
Update the panel size.
|
protected void |
validateTextComponentDocument()
Check if the 'document of the textComponent' has changed to another
document or not.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIaddAncestorListener, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, 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, validateTreeaction, 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, transferFocusUpCycleprotected Object textAntiAliasing
RenderingHints.protected Color borderColor
protected Color highlightedColor
protected int paddingLeft
protected int paddingRight
protected int borderWidth
protected JScrollPane scrollPane
protected JTextComponent textComponent
protected Document document
protected DocumentListener documentListener
document.protected int panelWidth
protected int largestRowNumber
panelWidth).protected int textComponentHeight
protected int lineNumberOffset
protected final List<Integer> highlightedLineList
protected boolean listenToDocumentUpdate
public JTextComponentRowHeader(JScrollPane scrollPane, JTextComponent textComponent)
scrollPane - the JScrollPane that it be added intotextComponent - the text component to listen the change events onprotected void validateTextComponentDocument()
public void checkPanelSize()
updatePanelSize().protected void updatePanelSize()
public void setFont(Font font)
setFont in class JComponentpublic void setForeground(Color foreground)
setForeground in class JComponentforeground - the colorpublic void setBackground(Color background)
setBackground in class JComponentbackground - the colorpublic Dimension getPreferredSize()
getPreferredSize in class JComponentpublic void paint(Graphics g)
paint in class JComponentpublic Object getTextAntiAliasing()
RenderingHints.public void setTextAntiAliasing(Object textAntiAliasing)
RenderingHints.textAntiAliasing - the settingpublic Color getBorderColor()
public void setBorderColor(Color borderColor)
borderColor - the colorpublic Color getHighlightedColor()
public void setHighlightedColor(Color highlightedColor)
highlightedColor - the colorpublic int getPaddingLeft()
public void setPaddingLeft(int paddingLeft)
paddingLeft - the padding in pixelpublic int getPaddingRight()
public void setPaddingRight(int paddingRight)
paddingRight - the padding in pixelpublic int getBorderWidth()
public void setBorderWidth(int borderWidth)
borderWidth - the width in pixelpublic int getLineNumberOffset()
public void setLineNumberOffset(int offset)
offset - the offsetpublic List<Integer> getHighlightedLineList()
public void setHighlightedLineList(List<Integer> highlightedLineList)
highlightedLineList - the list that contain the highlighted linespublic boolean addHighlightedLine(int lineNumber)
lineNumber - the line number to highlightList.add(Object)public void clearHighlightedLine()
public boolean isListenToDocumentUpdate()
public void setListenToDocumentUpdate(boolean listenToDocumentUpdate)
() after setting this to true.listenToDocumentUpdate - true to listen on document change, false notCopyright © 2015. All rights reserved.