Home
Categories
Dictionary
Download
Project Details
Changes Log
License

Defaults



The CodeEditorDefaults class handles the default properties of the Code Editor component.

Overview

The JEditor(CodeEditorDefaults) constructor allows to create the JEditor with specified defaults.

The CodeEditorDefaults class allows to specify how the editor will be presented:
  • Color for the keywords and comments
  • Used Fonts and Colors
  • Caret customization
  • etc...
For example:
      CodeEditorDefaults defaults = new CodeEditorDefaults();
      defaults.setStyle(Token.KEYWORD1, Color.BLUE, false, true);
      defaults.setStyle(Token.KEYWORD2, Color.BLUE, false, true);
      defaults.setStyle(Token.KEYWORD3, Color.BLUE, false, true);
      defaults.setStyle(Token.COMMENT1, Color.DARK_GRAY, false, false);
      defaults.setStyle(Token.COMMENT2, Color.DARK_GRAY, false, false);
      defaults.eolMarkers = false;
      defaults.paintInvalid = false;

      // create CodeEditor
      JEditor ta = new JEditor(defaults);

It is possible to create defaults from another defaults by using the CodeEditorDefaults(CodeEditorDefaults) constructor.

Setting the defaults again after the editor crration

The JEditor.setDefaults(CodeEditorDefaults) allows to set the defaults of the editor after its creation.

List of default properties

General properties

Field Usage
editable Specifies if the editor is editable (default is true)
cols The number of columns of the editor
rows The number of rows of the editor
tabSize The tabulation size
font The font of the editor
eolMarkerColor The color of the end of lines markers
eolMarkers Specifies if line markers are shown (default is true). End of line markers are "." characters
paintInvalid Specifies if empty lines are painted with a "~" character (default is true)

Caret properties

Field Usage
caretVisible Specifies if the caret is visible (default is true)
caretBlinks Specifies if the caret is blinking (default is true)
caretColor The color of the caret

Highlighting properties

Field Usage
selectionColor The color of text selection
lineHighlightColor The color of line selection selection
lineHighlight Specifies if line highlight is allowed (default is true)
bracketHighlightColor The color of brackets selection highlight
bracketHighlight Specifies if brackets highlight is allowed (default is true)
Field Usage
hasPopup Specifies if there is a popup which should appear for right-clicking in the editor area (default is false)
popup The Popup menu in the editor when right-clicking on the editor (default is null, tehre is no popup by default)

Gutter properties

Main Article: Gutter

Field Usage
gutterCollapsed Specifies if the gutter is initially copllapsed (default is true)
gutterExpandable Specifies if the gutter can be expanded (if collapsed) or collapsed (if expanded) (default is true)
gutterWidth The gutter width when it is expanded (default is 40 pixels)
gutterBgColor The gutter background color (default is white)
gutterFgColor The gutter foreground color (default is black)
gutterHighlightColor The gutter highlight color (default is Magenta)
gutterBorderColor The gutter border color (default is Gray)
gutterBorderWidth The gutter border width (default is 4 pixels)
gutterNumberAlignment The gutter number alignment (default is RIGHT)
gutterFont The gutter font (default is Monospaced)

The CodeEditorDefaults.removeGutter() will set these fields to remove the gutter. The CodeEditorDefaults.addGutter() allow to re-add the gutter if it was removed[1]
When calling this method, the gutterCollapsed, gutterExpandable, gutterFgColor, gutterBorderWidth, gutterBorderColor, gutterBgColor, and gutterHighlightColor fields are set. The addGutter() method will put their default values
.

Notes

  1. ^ When calling this method, the gutterCollapsed, gutterExpandable, gutterFgColor, gutterBorderWidth, gutterBorderColor, gutterBgColor, and gutterHighlightColor fields are set. The addGutter() method will put their default values

See also


Categories: component

Copyright 2016-2019 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence