本文整理了Java中javax.swing.JTextArea.getDocument()
方法的一些代码示例,展示了JTextArea.getDocument()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextArea.getDocument()
方法的具体详情如下:
包路径:javax.swing.JTextArea
类名称:JTextArea
方法名:getDocument
暂无
代码示例来源:origin: libgdx/libgdx
public void run () {
ui.textArea.append(text + "\n");
ui.textArea.setCaretPosition(ui.textArea.getDocument().getLength());
}
});
代码示例来源:origin: libgdx/libgdx
public void run () {
ui.textArea.append("" + c);
ui.textArea.setCaretPosition(ui.textArea.getDocument().getLength());
}
});
代码示例来源:origin: runelite/runelite
@Override
public void focusLost(FocusEvent e)
{
notesChanged(notesEditor.getDocument());
}
代码示例来源:origin: stackoverflow.com
Document document = textArea.getDocument();
int findLength = find.length();
try {
代码示例来源:origin: runelite/runelite
notesEditor.getDocument().addUndoableEditListener(e -> undoRedo.addEdit(e.getEdit()));
代码示例来源:origin: fossasia/neurolab-desktop
@Override
public void write(int b) throws IOException {
// redirects data to the text area
textArea.append(String.valueOf((char)b));
// scrolls the text area to the end of data
textArea.setCaretPosition(textArea.getDocument().getLength());
}
}
代码示例来源:origin: geotools/geotools
/** Clears the current text. */
private void onClear() {
int len = textArea.getDocument().getLength();
if (len > 0) {
try {
textArea.getDocument().remove(0, len);
} catch (BadLocationException ex) {
// this shouldn't happen
throw new IllegalStateException(ex);
}
}
}
代码示例来源:origin: opensourceBIM/BIMserver
@Override
public void write(byte[] bytes, int off, int len) throws IOException {
String str = new String(bytes, off, len);
systemOut.append(str);
logField.append(str);
logField.setCaretPosition(logField.getDocument().getLength());
}
代码示例来源:origin: opensourceBIM/BIMserver
@Override
public void write(int b) throws IOException {
String str = new String(new char[] { (char) b });
systemOut.append(str);
logField.append(str);
logField.setCaretPosition(logField.getDocument().getLength());
}
});
代码示例来源:origin: geotools/geotools
private void onCopyToClipboard() {
if (textArea.getDocument().getLength() > 0) {
StringSelection sel = new StringSelection(textArea.getText());
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
clip.setContents(sel, sel);
}
}
代码示例来源:origin: geotools/geotools
/**
* Appends the given text to that displayed. No additional newlines are added after the
* text.
*
* @param text the text to append
* @param indent indent width as number of spaces
*/
private void append(final String text, final int indent) {
String appendText;
if (indent > 0) {
char[] c = new char[indent];
Arrays.fill(c, ' ');
String pad = String.valueOf(c);
appendText = pad + text.replaceAll("\\n", "\n" + pad);
} else {
appendText = text;
}
textArea.append(appendText);
textArea.setCaretPosition(textArea.getDocument().getLength());
}
代码示例来源:origin: winder/Universal-G-Code-Sender
@Override
public void onMessage(MessageType messageType, String message) {
java.awt.EventQueue.invokeLater(() -> {
boolean verbose = messageType == MessageType.VERBOSE;
if (!verbose || showVerboseOutputCheckBox.isSelected()) {
String verboseS = "[" + Localization.getString("verbose") + "]";
consoleTextArea.append((verbose ? verboseS : "") + message);
if (consoleTextArea.isVisible() &&
scrollWindowCheckBox.isSelected()) {
consoleTextArea.setCaretPosition(consoleTextArea.getDocument().getLength());
}
}
});
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* Returns the text in which to search, as a string. This is used
* internally to grab the smallest buffer possible in which to search.
*/
private static String getFindInText(JTextArea textArea, int start,
boolean forward) {
// Be smart about the text we grab to search in. We grab more than
// a single line because our searches can return multi-line results.
// We copy only the chars that will be searched through.
String findIn = null;
try {
if (forward) {
findIn = textArea.getText(start,
textArea.getDocument().getLength()-start);
}
else { // backward
findIn = textArea.getText(0, start);
}
} catch (BadLocationException ble) {
// Never happens; findIn will be null anyway.
ble.printStackTrace();
}
return findIn;
}
代码示例来源:origin: winder/Universal-G-Code-Sender
private void checkScrollWindow() {
// Console output.
DefaultCaret caret = (DefaultCaret)consoleTextArea.getCaret();
if (scrollWindowCheckBox.isSelected()) {
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
consoleTextArea.setCaretPosition(consoleTextArea.getDocument().getLength());
} else {
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
}
// Command table.
this.commandTable.setAutoWindowScroll(scrollWindowCheckBox.isSelected());
}
代码示例来源:origin: winder/Universal-G-Code-Sender
private void checkScrollWindow() {
// Console output.
DefaultCaret caret = (DefaultCaret)consoleTextArea.getCaret();
if (scrollWindowMenuItem.isSelected()) {
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
consoleTextArea.setCaretPosition(consoleTextArea.getDocument().getLength());
} else {
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
}
}
代码示例来源:origin: winder/Universal-G-Code-Sender
/**
* When new messages are created this method will be called.
* It will decide using the {@code messageType} if the message should be written to the console.
*
* @param messageType the type of message to be written
* @param message the message to be written to the console
*/
@Override
public void onMessage(MessageType messageType, String message) {
java.awt.EventQueue.invokeLater(() -> {
boolean verbose = MessageType.VERBOSE.equals(messageType);
if (!verbose || showVerboseMenuItem.isSelected()) {
if (verbose) {
consoleTextArea.append("[" + messageType.getLocalizedString() + "] ");
}
consoleTextArea.append(message);
if (consoleTextArea.isVisible() && scrollWindowMenuItem.isSelected()) {
consoleTextArea.setCaretPosition(consoleTextArea.getDocument().getLength());
}
}
});
}
代码示例来源:origin: geotools/geotools
private void onSave() {
int len = textArea.getDocument().getLength();
if (len > 0) {
Writer writer = null;
代码示例来源:origin: ron190/jsql-injection
this.textInput.setLineWrap(true);
this.textInput.getDocument().addDocumentListener(new DocumentListenerTyping() {
代码示例来源:origin: ron190/jsql-injection
@Override
public void execute() {
if (MediatorGui.panelConsoles() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.panelConsoles() in "+ this.getClass());
}
MediatorGui.panelConsoles().getBinaryTab().append("\t"+ this.text);
MediatorGui.panelConsoles().getBinaryTab().setCaretPosition(MediatorGui.panelConsoles().getBinaryTab().getDocument().getLength());
int tabIndex = MediatorGui.tabConsoles().indexOfTab("Boolean");
if (0 <= tabIndex && tabIndex < MediatorGui.tabConsoles().getTabCount()) {
Component tabHeader = MediatorGui.tabConsoles().getTabComponentAt(tabIndex);
if (MediatorGui.tabConsoles().getSelectedIndex() != tabIndex) {
tabHeader.setFont(tabHeader.getFont().deriveFont(Font.BOLD));
}
}
}
代码示例来源:origin: ron190/jsql-injection
@Override
public void execute() {
if (MediatorGui.panelConsoles() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.panelConsoles() in "+ this.getClass());
}
try {
MediatorGui.panelConsoles().getChunkTab().append(this.text +"\n");
MediatorGui.panelConsoles().getChunkTab().setCaretPosition(MediatorGui.panelConsoles().getChunkTab().getDocument().getLength());
int tabIndex = MediatorGui.tabConsoles().indexOfTab("Chunk");
if (0 <= tabIndex && tabIndex < MediatorGui.tabConsoles().getTabCount()) {
Component tabHeader = MediatorGui.tabConsoles().getTabComponentAt(tabIndex);
if (MediatorGui.tabConsoles().getSelectedIndex() != tabIndex) {
tabHeader.setFont(tabHeader.getFont().deriveFont(Font.BOLD));
}
}
} catch(ArrayIndexOutOfBoundsException e) {
// Fix #4770 on chunkTab.append()
LOGGER.error(e.getMessage(), e);
}
}
内容来源于网络,如有侵权,请联系作者删除!