org.gjt.sp.jedit.syntax
Class SyntaxTextArea
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.text.JTextComponent
-
- javax.swing.JEditorPane
-
- org.gjt.sp.jedit.syntax.SyntaxTextArea
-
- All Implemented Interfaces:
- java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable
public class SyntaxTextArea extends javax.swing.JEditorPaneAn enhancedJEditorPaneuseful in text editors. It has the following advantages over the standard Swing text components:- Uses the
SyntaxEditorKitby default - Implements line highlighting, where the line the caret is on has a different background color
- Implements bracket highlighting, where if the caret is on a bracket, the matching one is highlighted.
- Has an optional block caret
- Implements overwrite mode that is toggled by pressing the Insert key
- See Also:
SyntaxEditorKit, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.DropLocation, javax.swing.text.JTextComponent.KeyBinding
-
-
Field Summary
Fields Modifier and Type Field and Description static javax.swing.text.EditorKitEDITOR_KITThe default editor kit for this text component.-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor and Description SyntaxTextArea()Creates a new SyntaxTextArea component.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description javax.swing.text.EditorKitcreateDefaultEditorKit()Returns the default editor kit for this text component.voiddoElectricScroll(java.awt.Rectangle rect)Works like Caret.adjustVisibility(), but does `electric' border scrolling (caret is never on the first or last visible line, if it ends up there the display is scrolled up or down)booleangetBlockCaret()Returns true if a block caret is enabled, false otherwise.booleangetBracketHighlight()Returns true if bracket highlighting is enabled, false otherwise.java.awt.ColorgetBracketHighlightColor()Returns the bracket highlight color.intgetElectricBorders()Returns the number of lines from the top or bottom of the text area from which autoscrolling begins.booleangetLineHighlight()Returns true if current line highlighting is enabled, false otherwise.java.awt.ColorgetLineHighlightColor()Returns the line highlight color.booleangetOverwrite(boolean overwrite)Returns true if overwrite mode is enabled, false otherwise.voidsetBlockCaret(boolean block)Sets the block caret.voidsetBracketHighlight(boolean bracketHighlight)Sets the bracket highlighting feature.voidsetBracketHighlightColor(java.awt.Color color)Sets the bracket highlight color.voidsetElectricBorders(int lines)Sets the number of lines from the top or bottom of the text area from which autoscroll begins.voidsetHighlightedBracket(int bracketPos)Sets the highlighted bracket.voidsetHighlightedLine(int lineStart, int lineEnd)Sets the currently highlighted line.voidsetLineHighlight(boolean lineHighlight)Sets the current line highlighting feature.voidsetLineHighlightColor(java.awt.Color color)Sets the line highlight color.voidsetOverwrite(boolean overwrite)Sets the overwrite mode.voidtoggleOverwrite()Sets the overwrite mode flag to the opposite of it's current value.voidupdateHighlighters()Updates the bracket and line highlighters.-
Methods inherited from class javax.swing.JEditorPane
addHyperlinkListener, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getText, getUIClassID, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, replaceSelection, scrollToReference, setContentType, setEditorKit, 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, setDocument, 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, hide, 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, 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, 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, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
EDITOR_KIT
public static final javax.swing.text.EditorKit EDITOR_KIT
The default editor kit for this text component.
-
-
Method Detail
-
createDefaultEditorKit
public javax.swing.text.EditorKit createDefaultEditorKit()
Returns the default editor kit for this text component.- Overrides:
createDefaultEditorKitin classjavax.swing.JEditorPane
-
setHighlightedLine
public void setHighlightedLine(int lineStart, int lineEnd)Sets the currently highlighted line.- Parameters:
lineStart- The start offset of the line in the documentlineEnd- The end offset of the line in the document
-
setLineHighlightColor
public void setLineHighlightColor(java.awt.Color color)
Sets the line highlight color.- Parameters:
color- The line highlight color
-
getLineHighlightColor
public java.awt.Color getLineHighlightColor()
Returns the line highlight color.
-
setLineHighlight
public void setLineHighlight(boolean lineHighlight)
Sets the current line highlighting feature.- Parameters:
lineHighlight- True if the current line should be highlighted, false otherwise.
-
getLineHighlight
public boolean getLineHighlight()
Returns true if current line highlighting is enabled, false otherwise.
-
setHighlightedBracket
public void setHighlightedBracket(int bracketPos)
Sets the highlighted bracket.- Parameters:
bracketPos- The offset of the bracket in the document
-
setBracketHighlightColor
public void setBracketHighlightColor(java.awt.Color color)
Sets the bracket highlight color.- Parameters:
color- The bracket highlight color
-
getBracketHighlightColor
public java.awt.Color getBracketHighlightColor()
Returns the bracket highlight color.
-
setBracketHighlight
public void setBracketHighlight(boolean bracketHighlight)
Sets the bracket highlighting feature.- Parameters:
bracketHighlight- True if matching brackets should be highlighted, false otherwise.
-
getBracketHighlight
public boolean getBracketHighlight()
Returns true if bracket highlighting is enabled, false otherwise.
-
setElectricBorders
public void setElectricBorders(int lines)
Sets the number of lines from the top or bottom of the text area from which autoscroll begins.- Parameters:
lines- The number of lines
-
getElectricBorders
public int getElectricBorders()
Returns the number of lines from the top or bottom of the text area from which autoscrolling begins.
-
setBlockCaret
public void setBlockCaret(boolean block)
Sets the block caret.- Parameters:
block- True if a block caret should be drawn, false otherwise
-
getBlockCaret
public boolean getBlockCaret()
Returns true if a block caret is enabled, false otherwise.
-
setOverwrite
public void setOverwrite(boolean overwrite)
Sets the overwrite mode.- Parameters:
overwrite- True if newly inserted characters should overwrite existing ones, false if they should be inserted.
-
getOverwrite
public boolean getOverwrite(boolean overwrite)
Returns true if overwrite mode is enabled, false otherwise.
-
toggleOverwrite
public void toggleOverwrite()
Sets the overwrite mode flag to the opposite of it's current value.
-
updateHighlighters
public void updateHighlighters()
Updates the bracket and line highlighters.
-
doElectricScroll
public void doElectricScroll(java.awt.Rectangle rect)
Works like Caret.adjustVisibility(), but does `electric' border scrolling (caret is never on the first or last visible line, if it ends up there the display is scrolled up or down)- Parameters:
rect- The rectangle to scroll to
-
-
DataMelt 3.0 © DataMelt by jWork.ORG