JTextArea PlainDocument
Move to any line in the JTextArea
Section titled “Move to any line in the JTextArea”
GotoLine
This will jump to the beginning of the JTextArea so that the specified line number is at the top.
Display JTextArea rows by hovering the mouse over them
Section titled “Display JTextArea rows by hovering the mouse over them”
MouseOverPainter
This displays a rollover of the line where the mouse cursor is located in the JTextArea.
Retrieve strings line by line from JTextArea
Section titled “Retrieve strings line by line from JTextArea”
GetLineText
This process extracts each line of text from a text component such as a JTextArea and then processes it.
Display line highlight cursor in JTextArea
Section titled “Display line highlight cursor in JTextArea”Display an image as the background of the JTextArea
Section titled “Display an image as the background of the JTextArea”
CentredBackgroundBorder
Display an image centered using a border as the background for components such as JTextArea.
Limit the number of lines that can be displayed in JTextArea
Section titled “Limit the number of lines that can be displayed in JTextArea”
FIFODocument
This keeps the document size constant and limits the number of lines that can be displayed, such as in JTextArea.
Display line numbers in JTextArea
Section titled “Display line numbers in JTextArea”
LineNumber
Create a component to display the row numbers of the JTextArea, and set it as the RowHeaderView of the same JScrollPane as the target JTextArea.
Display line cursor in JTextArea
Section titled “Display line cursor in JTextArea”
LineCursor
This underlines the entire line where the cursor is located in the JTextArea.
Enable overwrite mode for the caret in JTextArea
Section titled “Enable overwrite mode for the caret in JTextArea”
OverTypeMode
This adds an overwrite mode to JTextArea that overwrites the character on the caret.
Line movement using SmoothScroll in JTextArea
Section titled “Line movement using SmoothScroll in JTextArea”
SmoothScroll
This code uses a smooth scrolling animation to move to any line in the JTextArea.
Make a portion of the JTextArea uneditable
Section titled “Make a portion of the JTextArea uneditable”A JTextArea slides in as a caption on top of the image
Section titled “A JTextArea slides in as a caption on top of the image”Make the TableCellEditor scrollable
Section titled “Make the TableCellEditor scrollable”
ScrollingCellEditor
We will use JTextArea and JScrollPane as TableCellEditors for the JTable.
Configure the JTextArea so that only the last line is editable
Section titled “Configure the JTextArea so that only the last line is editable”
LastLineEditableTextArea
Use DocumentFilter to create a JTextArea where only the last line is editable.
Perform a highlighting search in JTextArea
Section titled “Perform a highlighting search in JTextArea”
HighlightSearch
This function searches for strings within a JTextArea based on specified criteria and highlights all matching strings.
Output Logger logs to JTextArea
Section titled “Output Logger logs to JTextArea”
TextAreaOutputStream
We will create an OutputStream and a StreamHandler to display the Logger's log output in a JTextArea.
Maintaining the display of selected state using the Caret in JTextArea
Section titled “Maintaining the display of selected state using the Caret in JTextArea”
CaretSelectionHighlight
Set a Caret for JTextComponents such as JTextArea, so that the selected text is highlighted even when it does not have focus.
Automatically copy text selected using the mouse within a JTextArea
Section titled “Automatically copy text selected using the mouse within a JTextArea”
CopyOnSelect
This mod adds a function to automatically copy selected text to the clipboard by setting up MouseListener and CareListener to capture events when text within a JTextArea is selected using the mouse.
Adjust the size by specifying the maximum width of the JTextArea placed in the JOptionPane
Section titled “Adjust the size by specifying the maximum width of the JTextArea placed in the JOptionPane”
MaxWidthWrapOptionPane
This setting specifies the maximum width of the JTextArea placed in the JOptionPane, ensuring that even if the text spans multiple lines, it will not exceed that width and will expand to a height where no scrollbar is displayed.
Change the delimiter when selecting words in JTextArea
Section titled “Change the delimiter when selecting words in JTextArea”
SelectWordAction
When you select a word by double-clicking a string in JTextArea, a character is added to be treated as a word separator.
Testing Caret movement when updating documents in JTextArea
Section titled “Testing Caret movement when updating documents in JTextArea”
CaretUpdatePolicy
This tests how Caret's update policy moves the location of a JTextArea document when it is updated.
When a JTextArea receives focus, its height will automatically expand
Section titled “When a JTextArea receives focus, its height will automatically expand”
ExpandingTextArea
When a JTextArea receives focus, its height automatically expands; when it loses focus, it shrinks.
Displays the Unicode code point of the character at the Caret position within the JTextArea
Section titled “Displays the Unicode code point of the character at the Caret position within the JTextArea”
CodePointAtCaret
This displays the Unicode code point of the character located next to 'Caret' within the JTextArea in a JTextField.
Make JTextArea scrollable beyond the last line
Section titled “Make JTextArea scrollable beyond the last line”
ScrollBeyondLastLine
This expands the height of the JTextArea so that it can be scrolled beyond its last line.
Modify the JTextArea’s Caret to change the behavior of word selection by double-clicking with the mouse
Section titled “Modify the JTextArea’s Caret to change the behavior of word selection by double-clicking with the mouse”
ContinuouslySelectWords
Modify the Caret of the JTextArea so that after selecting a word with a double-click of the mouse, the selection range will extend to the next word when you continue dragging.
Get the character type of the text within a JTextArea
Section titled “Get the character type of the text within a JTextArea”
UnicodeBlock
This function retrieves the Unicode block of the character located at the Caret position within the JTextArea and displays it in a JTextField.
Create a cell editor using JTextArea and JFrame that allows for fixed width, text wrapping, and height expansion beyond the parent frame
Section titled “Create a cell editor using JTextArea and JFrame that allows for fixed width, text wrapping, and height expansion beyond the parent frame”
LineWrapListEditor
A JTextArea is configured to have a fixed width and adjustable height with wrapping based on the length of the text. This is then placed in a JFrame and used as a JList cell label editor that can be displayed outside of its parent frame.
Remove all highlights set in the JTextArea
Section titled “Remove all highlights set in the JTextArea”
RemoveAllHighlights
This command removes all highlights set in a JTextArea, or removes all highlights except for selected highlights.
Press and hold the JTextArea with your mouse to select words, etc
Section titled “Press and hold the JTextArea with your mouse to select words, etc”
TextComponentMouseListener
We will add a MouseListener to the JTextArea, enabling features such as word selection by long-pressing the left mouse button and focus movement by right-clicking.
Add a border to the search highlight in JTextArea
Section titled “Add a border to the search highlight in JTextArea”
BorderHighlightPainter
Sets the border color for highlighting applied to search strings in JTextArea.
Place a JTextArea in a JToolTip to automatically wrap lines
Section titled “Place a JTextArea in a JToolTip to automatically wrap lines”
LineWrapToolTip
By placing a JTextArea in a JToolTip, lines that are too long to fit within the allocated width will automatically wrap.
Round all corners and make the selected text highlight of a JTextComponent semi-transparent
Section titled “Round all corners and make the selected text highlight of a JTextComponent semi-transparent”
TranslucentRoundedSelection
This sets the Caret used by JTextComponents such as JTextArea and JEditorPane to use HighlightPainter, which rounds all corners of the selected text highlight and renders it semi-transparent.
Move the caret in the JTextArea to the wrap point at the right edge, then to the newline character
Section titled “Move the caret in the JTextArea to the wrap point at the right edge, then to the newline character”
CursorEndAction
Configure the caret movement action of JTextArea so that it transitions first to the rightmost wrap position on the display, and then next to the newline character position.
Edit text in a JTextField on multiple lines in a JTextArea placed in a JPopupMenu
Section titled “Edit text in a JTextField on multiple lines in a JTextArea placed in a JPopupMenu”
ExpandableTextField
Copy single-line text separated by spaces from a JTextField into a JTextArea placed in a JPopupMenu to enable multi-line editing.