public class Gutter
extends javax.swing.JPanel
Icons can be added on a per-line basis to visually mark syntax errors, lines
with breakpoints set on them, etc. To add icons to the gutter, you must
first call RTextScrollPane.setIconRowHeaderEnabled(boolean)
on the
parent scroll pane, to make the icon area visible. Then, you can add icons
that track either lines in the document, or offsets, via
addLineTrackingIcon(int, Icon)
and
addOffsetTrackingIcon(int, Icon)
, respectively. To remove an
icon you've added, use removeTrackingIcon(GutterIconInfo)
.
In addition to support for arbitrary per-line icons, this component also has built-in support for displaying icons representing "bookmarks;" that is, lines a user can cycle through via F2 and Shift+F2. Bookmarked lines are toggled via Ctrl+F2. In order to enable bookmarking, you must first assign an icon to represent a bookmarked line, then actually enable the feature:
Gutter gutter = scrollPane.getGutter(); gutter.setBookmarkIcon(new ImageIcon("bookmark.png")); gutter.setBookmarkingEnabled(true);
GutterIconInfo
,
序列化表格限定符和类型 | 字段和说明 |
---|---|
static java.awt.Color |
DEFAULT_ACTIVE_LINE_RANGE_COLOR
The color used to highlight active line ranges if none is specified.
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
限定符和类型 | 方法和说明 |
---|---|
GutterIconInfo |
addLineTrackingIcon(int line,
javax.swing.Icon icon)
Adds an icon that tracks an offset in the document, and is displayed
adjacent to the line numbers.
|
GutterIconInfo |
addLineTrackingIcon(int line,
javax.swing.Icon icon,
java.lang.String tip)
Adds an icon that tracks an offset in the document, and is displayed
adjacent to the line numbers.
|
GutterIconInfo |
addOffsetTrackingIcon(int offs,
javax.swing.Icon icon)
Adds an icon that tracks an offset in the document, and is displayed
adjacent to the line numbers.
|
GutterIconInfo |
addOffsetTrackingIcon(int offs,
javax.swing.Icon icon,
java.lang.String tip)
Adds an icon that tracks an offset in the document, and is displayed
adjacent to the line numbers.
|
java.awt.Color |
getActiveLineRangeColor()
Returns the color used to paint the active line range, if any.
|
javax.swing.Icon |
getBookmarkIcon()
Returns the icon to use for bookmarks.
|
GutterIconInfo[] |
getBookmarks()
Returns the bookmarks known to this gutter.
|
java.awt.Color |
getBorderColor()
Returns the color of the "border" line.
|
java.awt.Color |
getFoldBackground()
Returns the background color used by the (default) fold icons.
|
java.awt.Color |
getFoldIndicatorForeground()
Returns the foreground color of the fold indicator.
|
java.awt.Color |
getLineNumberColor()
Returns the color to use to paint line numbers.
|
java.awt.Font |
getLineNumberFont()
Returns the font used for line numbers.
|
int |
getLineNumberingStartIndex()
Returns the starting line's line number.
|
boolean |
getLineNumbersEnabled()
Returns
true if the line numbers are enabled and visible. |
boolean |
getShowCollapsedRegionToolTips()
Returns whether tool tips are displayed showing the contents of
collapsed fold regions when the mouse hovers over a +/- icon.
|
GutterIconInfo[] |
getTrackingIcons(java.awt.Point p)
Returns the tracking icons at the specified view position.
|
boolean |
isBookmarkingEnabled()
Returns whether bookmarking is enabled.
|
boolean |
isFoldIndicatorEnabled()
Returns whether the fold indicator is enabled.
|
boolean |
isIconRowHeaderEnabled()
Returns whether the icon row header is enabled.
|
void |
removeAllTrackingIcons()
Removes all tracking icons.
|
void |
removeTrackingIcon(GutterIconInfo tag)
Removes the specified tracking icon.
|
void |
setActiveLineRangeColor(java.awt.Color color)
Sets the color to use to render active line ranges.
|
void |
setBookmarkIcon(javax.swing.Icon icon)
Sets the icon to use for bookmarks.
|
void |
setBookmarkingEnabled(boolean enabled)
Sets whether bookmarking is enabled.
|
void |
setBorder(javax.swing.border.Border border) |
void |
setBorderColor(java.awt.Color color)
Sets the color for the "border" line.
|
void |
setComponentOrientation(java.awt.ComponentOrientation o) |
void |
setFoldBackground(java.awt.Color bg)
Sets the background color used by the (default) fold icons.
|
void |
setFoldIcons(javax.swing.Icon collapsedIcon,
javax.swing.Icon expandedIcon)
Sets the icons to use to represent collapsed and expanded folds.
|
void |
setFoldIndicatorEnabled(boolean enabled)
Toggles whether the fold indicator is enabled.
|
void |
setFoldIndicatorForeground(java.awt.Color fg)
Sets the foreground color used by the fold indicator.
|
void |
setLineNumberColor(java.awt.Color color)
Sets the color to use to paint line numbers.
|
void |
setLineNumberFont(java.awt.Font font)
Sets the font used for line numbers.
|
void |
setLineNumberingStartIndex(int index)
Sets the starting line's line number.
|
void |
setShowCollapsedRegionToolTips(boolean show)
Toggles whether tool tips should be displayed showing the contents of
collapsed fold regions when the mouse hovers over a +/- icon.
|
boolean |
toggleBookmark(int line)
Programatically toggles whether there is a bookmark for the specified
line.
|
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, 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, setBackground, 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, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.awt.Color DEFAULT_ACTIVE_LINE_RANGE_COLOR
public Gutter(RTextArea textArea)
textArea
- The parent text area.public GutterIconInfo addLineTrackingIcon(int line, javax.swing.Icon icon) throws javax.swing.text.BadLocationException
line
- The line to track (zero-based).icon
- The icon to display. This should be small (say 16x16).removeTrackingIcon(GutterIconInfo)
to remove this
icon.javax.swing.text.BadLocationException
- If offs
is an invalid offset
into the text area.addLineTrackingIcon(int, Icon, String)
,
addOffsetTrackingIcon(int, Icon)
,
removeTrackingIcon(GutterIconInfo)
public GutterIconInfo addLineTrackingIcon(int line, javax.swing.Icon icon, java.lang.String tip) throws javax.swing.text.BadLocationException
line
- The line to track (zero-based).icon
- The icon to display. This should be small (say 16x16).tip
- An optional tool tip for the icon.removeTrackingIcon(GutterIconInfo)
to remove this
icon.javax.swing.text.BadLocationException
- If offs
is an invalid offset
into the text area.addLineTrackingIcon(int, Icon)
,
addOffsetTrackingIcon(int, Icon)
,
removeTrackingIcon(GutterIconInfo)
public GutterIconInfo addOffsetTrackingIcon(int offs, javax.swing.Icon icon) throws javax.swing.text.BadLocationException
offs
- The offset to track.icon
- The icon to display. This should be small (say 16x16).javax.swing.text.BadLocationException
- If offs
is an invalid offset
into the text area.addOffsetTrackingIcon(int, Icon, String)
,
addLineTrackingIcon(int, Icon)
,
removeTrackingIcon(GutterIconInfo)
public GutterIconInfo addOffsetTrackingIcon(int offs, javax.swing.Icon icon, java.lang.String tip) throws javax.swing.text.BadLocationException
offs
- The offset to track.icon
- The icon to display. This should be small (say 16x16).tip
- An optional tool tip for the icon.javax.swing.text.BadLocationException
- If offs
is an invalid offset
into the text area.addOffsetTrackingIcon(int, Icon)
,
addLineTrackingIcon(int, Icon)
,
removeTrackingIcon(GutterIconInfo)
public java.awt.Color getActiveLineRangeColor()
setActiveLineRangeColor(Color)
public javax.swing.Icon getBookmarkIcon()
null
,
bookmarking is effectively disabled.setBookmarkIcon(Icon)
,
isBookmarkingEnabled()
public GutterIconInfo[] getBookmarks()
public java.awt.Color getBorderColor()
setBorderColor(Color)
public java.awt.Color getFoldBackground()
setFoldBackground(Color)
public java.awt.Color getFoldIndicatorForeground()
setFoldIndicatorForeground(Color)
public java.awt.Color getLineNumberColor()
setLineNumberColor(Color)
public java.awt.Font getLineNumberFont()
setLineNumberFont(Font)
public int getLineNumberingStartIndex()
1
.setLineNumberingStartIndex(int)
public boolean getLineNumbersEnabled()
true
if the line numbers are enabled and visible.public boolean getShowCollapsedRegionToolTips()
setShowCollapsedRegionToolTips(boolean)
public GutterIconInfo[] getTrackingIcons(java.awt.Point p) throws javax.swing.text.BadLocationException
p
- The view position.javax.swing.text.BadLocationException
- If p
is invalid.public boolean isFoldIndicatorEnabled()
setFoldIndicatorEnabled(boolean)
public boolean isBookmarkingEnabled()
setBookmarkingEnabled(boolean)
public boolean isIconRowHeaderEnabled()
public void removeTrackingIcon(GutterIconInfo tag)
tag
- A tag for an icon in the gutter, as returned from either
addLineTrackingIcon(int, Icon)
or
addOffsetTrackingIcon(int, Icon)
.removeAllTrackingIcons()
,
addLineTrackingIcon(int, Icon)
,
addOffsetTrackingIcon(int, Icon)
public void removeAllTrackingIcons()
public void setActiveLineRangeColor(java.awt.Color color)
color
- The color to use. If this is null, then the default
color is used.getActiveLineRangeColor()
,
DEFAULT_ACTIVE_LINE_RANGE_COLOR
public void setBookmarkIcon(javax.swing.Icon icon)
icon
- The new bookmark icon. If this is null
,
bookmarking is effectively disabled.getBookmarkIcon()
,
isBookmarkingEnabled()
public void setBookmarkingEnabled(boolean enabled)
setBookmarkIcon(Icon)
before bookmarks are
truly enabled.enabled
- Whether bookmarking is enabled.isBookmarkingEnabled()
,
setBookmarkIcon(Icon)
public void setBorderColor(java.awt.Color color)
color
- The new color.getBorderColor()
public void setComponentOrientation(java.awt.ComponentOrientation o)
setComponentOrientation
在类中 java.awt.Component
public void setFoldIcons(javax.swing.Icon collapsedIcon, javax.swing.Icon expandedIcon)
collapsedIcon
- The collapsed fold icon. This cannot be
null
.expandedIcon
- The expanded fold icon. This cannot be
null
.public void setFoldIndicatorEnabled(boolean enabled)
enabled
- Whether the fold indicator should be enabled.isFoldIndicatorEnabled()
public void setFoldBackground(java.awt.Color bg)
bg
- The new background color.getFoldBackground()
public void setFoldIndicatorForeground(java.awt.Color fg)
fg
- The new fold indicator foreground.getFoldIndicatorForeground()
public void setLineNumberColor(java.awt.Color color)
color
- The color to use when painting line numbers.getLineNumberColor()
public void setLineNumberFont(java.awt.Font font)
font
- The font to use. This cannot be null
.getLineNumberFont()
public void setLineNumberingStartIndex(int index)
1
. Applications can call this method to change this value
if they are displaying a subset of lines in a file, for example.index
- The new index.getLineNumberingStartIndex()
public void setShowCollapsedRegionToolTips(boolean show)
show
- Whether to show these tool tips.getShowCollapsedRegionToolTips()
public boolean toggleBookmark(int line) throws javax.swing.text.BadLocationException
line
- The line.javax.swing.text.BadLocationException
- If line
is an invalid line
number in the text area.public void setBorder(javax.swing.border.Border border)
setBorder
在类中 javax.swing.JComponent