本文整理了Java中javax.swing.text.AbstractDocument.replace()
方法的一些代码示例,展示了AbstractDocument.replace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractDocument.replace()
方法的具体详情如下:
包路径:javax.swing.text.AbstractDocument
类名称:AbstractDocument
方法名:replace
暂无
代码示例来源:origin: bobbylight/RSyntaxTextArea
((AbstractDocument)doc).replace(start, end - start,
str, null);
} catch (BadLocationException e) {
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-project
public void run() {
String text = field.getText().trim();
if (text.length() > 0 && Character.isLowerCase(text.charAt(0))) {
boolean wasEditing = userEdit;
try {
userEdit = false;
((AbstractDocument)field.getDocument()).replace(0, 1, ""+Character.toUpperCase(text.charAt(0)), null);
} catch (BadLocationException ble) {
Exceptions.printStackTrace(ble);
} finally {
userEdit = wasEditing;
}
}
}
});
代码示例来源:origin: net.sf.cuf/cuf-swing
if (mDocument instanceof AbstractDocument)
((AbstractDocument)mDocument).replace(0, mDocument.getLength(), pContent, null);
代码示例来源:origin: org.appdapter/org.appdapter.lib.gui
public void replaceRange(String str, int start, int end) {
if (end < start) {
throw new IllegalArgumentException("end before start");
}
Document doc = getDocument();
if (doc != null) {
try {
if (doc instanceof AbstractDocument) {
((AbstractDocument) doc).replace(start, end - start, str, null);
} else {
doc.remove(start, end - start);
doc.insertString(start, str, null);
}
} catch (BadLocationException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
/**
* Accessor for text area.
* This is used by Actions that need to act on the text area of the View.
*/
public void replaceRange(String str, int start, int end) {
//editor.replaceRange(str, start, end);
if (end < start) {
throw new IllegalArgumentException("end before start");
}
Document doc = getDocument();
if (doc != null) {
try {
if (doc instanceof AbstractDocument) {
((AbstractDocument) doc).replace(start, end - start, str,
null);
} else {
doc.remove(start, end - start);
doc.insertString(start, str, null);
}
} catch (BadLocationException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
}
代码示例来源:origin: omegat-org/omegat
public void actionPerformed(ActionEvent e) {
try {
int pos = comp.getCaretPosition();
xlDoc.replace(wordStart, wordLength, replacement, null);
comp.setCaretPosition(pos);
} catch (BadLocationException exc) {
Log.log(exc);
}
}
});
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
try {
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).replace(start, end - start, str,
null);
代码示例来源:origin: beryx/text-io
private boolean plainReplaceText(String message, StyleData styleData) {
if(overwriteOffset >= document.getLength()) {
overwriteOffset = -1;
}
if(overwriteOffset < 0) return plainInsertMessage(message, styleData);
String styleName = getStyle(styleData);
int oldStartReadLen = startReadLen;
if(startReadLen > overwriteOffset) {
startReadLen = overwriteOffset;
}
boolean result = true;
try {
int len = Math.min(document.getLength() - overwriteOffset, message.length());
((AbstractDocument) document).replace(overwriteOffset, len, message, document.getStyle(styleName));
overwriteOffset += message.length();
} catch (BadLocationException e) {
logger.error("Cannot replace text", e);
startReadLen = oldStartReadLen;
result = false;
}
return result;
}
代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core
public static void setTextToDocument(final PlainDocument document, final String text) {
GuiUtilities.invokeLater(() -> {
try {
((AbstractDocument) document).replace(0, document.getLength(), text, null);
} catch (final BadLocationException exception) {
logger.log(ILevel.FATAL, exception.getLocalizedMessage(), exception);
}
});
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-editor
((AbstractDocument)doc).replace(start, end - start,
str, null);
} catch (BadLocationException e) {
代码示例来源:origin: com.fifesoft/rsyntaxtextarea
((AbstractDocument)doc).replace(start, end - start,
str, null);
} catch (BadLocationException e) {
代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea
((AbstractDocument)doc).replace(start, end - start,
str, null);
} catch (BadLocationException e) {
代码示例来源:origin: bbuck/DragonConsole
try {
if (consoleInputMethod)
((AbstractDocument)console.getStyledDocument()).replace(rangeStart, end, BYPASS + input.get(), inputAttr);
else
((AbstractDocument)console.getStyledDocument()).replace(rangeStart, end, input.get(), inputAttr);
代码示例来源:origin: org.integratedmodelling/klab-common
try {
if (consoleInputMethod)
((AbstractDocument)console.getStyledDocument()).replace(rangeStart, end, BYPASS + input.get(), inputAttr);
else
((AbstractDocument)console.getStyledDocument()).replace(rangeStart, end, input.get(), inputAttr);
代码示例来源:origin: stackoverflow.com
try {
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).replace(start, end - start, str, null);
代码示例来源:origin: com.fifesoft/autocomplete
((AbstractDocument)doc).replace(start, len, replacement, null);
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
private void maybeUpdateDoc( int iOffset, int iLength, String pattern )
{
Path file = getNode().getFile().getFileOrDir();
EditorHost editor = LabFrame.instance().getGosuPanel().findTab( file );
if( editor == null )
{
return;
}
editor.getUndoManager().beginUndoAtom( "Replace" );
try
{
((AbstractDocument)editor.getEditor().getDocument()).replace( iOffset, iLength, pattern, null );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
finally
{
editor.getUndoManager().endUndoAtom();
}
IType type = getNode().getFile().getType();
if( type != null )
{
TypeSystem.refresh( (ITypeRef)type );
}
}
内容来源于网络,如有侵权,请联系作者删除!