public class TextLineNumber
extends javax.swing.JPanel
implements javax.swing.event.CaretListener, javax.swing.event.DocumentListener, java.beans.PropertyChangeListener
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static float |
CENTER |
static float |
LEFT |
static float |
RIGHT |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
TextLineNumber(javax.swing.text.JTextComponent component,
javax.swing.JScrollPane scroll)
Create a line number component for a text component.
|
TextLineNumber(javax.swing.text.JTextComponent component,
javax.swing.JScrollPane scroll,
int minimumDisplayDigits)
Create a line number component for a text component.
|
Modifier and Type | Method and Description |
---|---|
void |
caretUpdate(javax.swing.event.CaretEvent e) |
void |
changedUpdate(javax.swing.event.DocumentEvent e) |
int |
getBorderGap()
Gets the border gap
|
java.awt.Color |
getCurrentLineForeground()
Gets the current line rendering Color
|
float |
getDigitAlignment()
Gets the digit alignment
|
int |
getMinimumDisplayDigits()
Gets the minimum display digits
|
protected java.lang.String |
getTextLineNumber(int rowStartOffset) |
boolean |
getUpdateFont()
Gets the update font property
|
void |
init() |
void |
insertUpdate(javax.swing.event.DocumentEvent e) |
void |
install() |
void |
paintComponent(java.awt.Graphics g)
Draw the line numbers
|
void |
propertyChange(java.beans.PropertyChangeEvent evt) |
void |
removeUpdate(javax.swing.event.DocumentEvent e) |
void |
setBorderGap(int borderGap)
The border gap is used in calculating the left and right insets of the
border.
|
void |
setCurrentLineForeground(java.awt.Color currentLineForeground)
The Color used to render the current line digits.
|
void |
setDigitAlignment(float digitAlignment)
Specify the horizontal alignment of the digits within the component.
|
void |
setMinimumDisplayDigits(int minimumDisplayDigits)
Specify the mimimum number of digits used to calculate the preferred
width of the component.
|
void |
setUpdateFont(boolean updateFont)
Set the update font property.
|
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, 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
public static final float LEFT
public static final float CENTER
public static final float RIGHT
public TextLineNumber(javax.swing.text.JTextComponent component, javax.swing.JScrollPane scroll)
component
- the related text componentpublic TextLineNumber(javax.swing.text.JTextComponent component, javax.swing.JScrollPane scroll, int minimumDisplayDigits)
component
- the related text componentminimumDisplayDigits
- the number of digits used to calculate the
minimum width of the componentpublic void init()
public boolean getUpdateFont()
public void setUpdateFont(boolean updateFont)
updateFont
- when true update the Font and repaint the line numbers,
otherwise just repaint the line numbers.public int getBorderGap()
public void setBorderGap(int borderGap)
borderGap
- the gap in pixelspublic java.awt.Color getCurrentLineForeground()
public void setCurrentLineForeground(java.awt.Color currentLineForeground)
currentLineForeground
- the Color used to render the current linepublic float getDigitAlignment()
public void setDigitAlignment(float digitAlignment)
currentLineForeground
- the Color used to render the current linepublic int getMinimumDisplayDigits()
public void setMinimumDisplayDigits(int minimumDisplayDigits)
minimumDisplayDigits
- the number digits used in the preferred width
calculationpublic void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
protected java.lang.String getTextLineNumber(int rowStartOffset)
public void caretUpdate(javax.swing.event.CaretEvent e)
caretUpdate
in interface javax.swing.event.CaretListener
public void changedUpdate(javax.swing.event.DocumentEvent e)
changedUpdate
in interface javax.swing.event.DocumentListener
public void insertUpdate(javax.swing.event.DocumentEvent e)
insertUpdate
in interface javax.swing.event.DocumentListener
public void removeUpdate(javax.swing.event.DocumentEvent e)
removeUpdate
in interface javax.swing.event.DocumentListener
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener
public void install()