The list of methods to do JTextArea are organized into topic(s).
void
addMessageLogger(JTextArea t) Add the given component into the list of components that show messages from the message method calls
messageLogs.add(t);
void
addStyle(JTextArea textArea, String labelName, boolean isBorder) add Style
Border border = null;
if (isBorder) {
Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
TitledBorder titled = BorderFactory.createTitledBorder(line, labelName);
titled.setTitleFont(new Font("Verdana", 0, 13));
titled.setTitleColor(new Color(213, 225, 185));
Border empty = new EmptyBorder(5, 8, 5, 8);
CompoundBorder cBorder = new CompoundBorder(titled, empty);
...
void
applyDefaultProperties(final JTextArea comp) Sets default background and foreground color as well as a default font for the specified component.
if (comp == null) {
return;
applyProperties(comp, "TextArea.background",
"TextArea.foreground",
"TextArea.font");
void
attachSimpleUndoManager(JTextArea jta) attach Simple Undo Manager
UndoManager um = new UndoManager();
jta.getDocument().addUndoableEditListener(um);
jta.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("control Z"),
"doUndo");
jta.getActionMap().put("doUndo", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (um.canUndo())
...
void
blockUncomment(JTextArea scriptPanel) Block uncomment the selected text in the given script panel.
final int startOffset = scriptPanel.getSelectionStart();
final int endOffset = scriptPanel.getSelectionEnd();
scriptPanel.replaceRange("", endOffset - BLOCK_COMMENT_END.length(), endOffset);
scriptPanel.replaceRange("", startOffset, startOffset + BLOCK_COMMENT_START.length());
scriptPanel.setSelectionStart(startOffset);
scriptPanel.setSelectionEnd(endOffset - BLOCK_COMMENT_START.length() - BLOCK_COMMENT_END.length());
void
commentSQL(JTextArea scriptPanel, String commentCharacter) Comment the selected text in the given script panel.
final Element root = scriptPanel.getDocument().getDefaultRootElement();
final int numberOfLastLine = root.getElementIndex(scriptPanel.getSelectionEnd());
int currentLineNumber = root.getElementIndex(scriptPanel.getSelectionStart());
while (currentLineNumber <= numberOfLastLine) {
scriptPanel.insert(commentCharacter, root.getElement(currentLineNumber).getStartOffset());
currentLineNumber++;