|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
jsyntaxpane.components.LineNumbersRuler
public class LineNumbersRuler
This class will display line numbers for a related text component. The text component must use the same line height for each line. This class was designed to be used as a component added to the row header of a JScrollPane. Original code from http://tips4java.wordpress.com/2009/05/23/text-component-line-number/
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JPanel |
|---|
javax.swing.JPanel.AccessibleJPanel |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
javax.swing.JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
java.awt.Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Nested classes/interfaces inherited from interface jsyntaxpane.components.SyntaxComponent |
|---|
SyntaxComponent.Status |
| Field Summary | |
|---|---|
static int |
DEFAULT_L_MARGIN
|
static int |
DEFAULT_R_MARGIN
|
static java.lang.String |
PROPERTY_BACKGROUND
|
static java.lang.String |
PROPERTY_CURRENT_BACK
|
static java.lang.String |
PROPERTY_FOREGROUND
|
static java.lang.String |
PROPERTY_LEFT_MARGIN
|
static java.lang.String |
PROPERTY_RIGHT_MARGIN
|
static java.lang.String |
PROPERTY_Y_OFFSET
|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
LineNumbersRuler()
|
|
| Method Summary | |
|---|---|
void |
caretUpdate(javax.swing.event.CaretEvent e)
|
void |
changedUpdate(javax.swing.event.DocumentEvent e)
|
void |
config(Configuration config)
Configure the component using the given properties. |
void |
deinstall(javax.swing.JEditorPane editor)
Called when the component is to be removed from the editor |
int |
getMinimumDisplayDigits()
Gets the minimum display digits |
javax.swing.JScrollPane |
getScrollPane(javax.swing.text.JTextComponent editorPane)
Get the JscrollPane that contains this EditorPane, or null if no JScrollPane is the parent of this editor |
void |
insertUpdate(javax.swing.event.DocumentEvent e)
|
void |
install(javax.swing.JEditorPane editor)
Called to install the component on an editor |
void |
paintComponent(java.awt.Graphics g)
Draw the line numbers |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
Implement PropertyChangeListener interface |
void |
removeUpdate(javax.swing.event.DocumentEvent e)
|
void |
setMinimumDisplayDigits(int minimumDisplayDigits)
Specify the minimum number of digits used to calculate the preferred width of the component. |
| Methods inherited from class javax.swing.JPanel |
|---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
|---|
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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 |
| Methods inherited from class java.awt.Container |
|---|
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, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
|---|
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, 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, 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, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String PROPERTY_BACKGROUND
public static final java.lang.String PROPERTY_FOREGROUND
public static final java.lang.String PROPERTY_CURRENT_BACK
public static final java.lang.String PROPERTY_LEFT_MARGIN
public static final java.lang.String PROPERTY_RIGHT_MARGIN
public static final java.lang.String PROPERTY_Y_OFFSET
public static final int DEFAULT_R_MARGIN
public static final int DEFAULT_L_MARGIN
| Constructor Detail |
|---|
public LineNumbersRuler()
| Method Detail |
|---|
public javax.swing.JScrollPane getScrollPane(javax.swing.text.JTextComponent editorPane)
editorPane -
public void config(Configuration config)
SyntaxComponent
config in interface SyntaxComponentconfig - configuration datapublic void install(javax.swing.JEditorPane editor)
SyntaxComponent
install in interface SyntaxComponentpublic void deinstall(javax.swing.JEditorPane editor)
SyntaxComponent
deinstall in interface SyntaxComponentpublic 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.JComponentpublic void caretUpdate(javax.swing.event.CaretEvent e)
caretUpdate in interface javax.swing.event.CaretListenerpublic void changedUpdate(javax.swing.event.DocumentEvent e)
changedUpdate in interface javax.swing.event.DocumentListenerpublic void insertUpdate(javax.swing.event.DocumentEvent e)
insertUpdate in interface javax.swing.event.DocumentListenerpublic void removeUpdate(javax.swing.event.DocumentEvent e)
removeUpdate in interface javax.swing.event.DocumentListenerpublic void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||