本文整理了Java中javax.swing.text.StyledDocument.remove()
方法的一些代码示例,展示了StyledDocument.remove()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StyledDocument.remove()
方法的具体详情如下:
包路径:javax.swing.text.StyledDocument
类名称:StyledDocument
方法名:remove
暂无
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor
@Override
public void run() {
try {
int documentOffset = sourceOffset;
document.remove(documentOffset, caretOffset - documentOffset);
document.insertString(documentOffset, text, null);
} catch (BadLocationException ex) {
}
}
});
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public void run() {
try {
doc.removeDocumentListener(getListener());
doc.remove(0, doc.getLength()); // remove all text
doc.addDocumentListener(getListener());
} catch(BadLocationException ble) {
ErrorManager.getDefault().notify(
ErrorManager.INFORMATIONAL, ble);
}
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf
@Override
public void run() {
try {
doc.remove(0, passPrologLen + 1); // +1 it removes exclusive
doc.insertString(0, "<?xml version='1.0' encoding='UTF-8' ?> \n<!-- was: " + new String(prolog, 0, passPrologLen + 1) + " -->", null); // NOI18N
} catch (BadLocationException e) {
if (System.getProperty("netbeans.debug.exceptions") != null) { // NOI18N
Exceptions.printStackTrace(e);
}
}
}
};
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public void run() {
try {
doc.removeDocumentListener(getListener());
doc.remove(0, doc.getLength()); // remove all text
doc.addDocumentListener(getListener());
} catch(BadLocationException ble) {
ErrorManager.getDefault().notify(
ErrorManager.INFORMATIONAL, ble);
}
}
});
代码示例来源:origin: Vhati/Slipstream-Mod-Manager
public void clear() {
try {
doc.remove( 0, doc.getLength() );
}
catch ( BadLocationException e ) {
log.error( "Error clearing info text area", e );
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2
void clear() {
try {
styledDoc.remove(0, styledDoc.getLength());
} catch (BadLocationException ble1) {
System.err.println("View.clear(): Couldn't remove initial text from document.");
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-jboss4
public void run() {
try {
doc.remove(0, doc.getLength());
doc.insertString(0, out.toString(), null);
} catch (BadLocationException ble) {
Exceptions.printStackTrace(ble);
}
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-tomcat5
public void run() {
try {
doc.remove(0, doc.getLength());
doc.insertString(0, out.toString(), null);
} catch (BadLocationException ble) {
Exceptions.printStackTrace(ble);
}
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-core
public void run() {
try {
doc.remove(0, passPrologLen + 1); // +1 it removes exclusive
doc.insertString(0, "<?xml version='1.0' encoding='UTF-8' ?> \n<!-- was: " + new String(prolog, 0, passPrologLen + 1) + " -->", null); // NOI18N
} catch (BadLocationException e) {
if (System.getProperty("netbeans.debug.exceptions") != null) // NOI18N
e.printStackTrace();
}
}
};
代码示例来源:origin: chatty/chatty
/**
* Set this text pane to a new text. Removes any previous content and adds
* the new text while adding clickablel links.
*
* @param text
*/
@Override
public void setText(String text) {
try {
doc.remove(0, doc.getLength());
} catch (BadLocationException ex) {
LOGGER.warning("Bad location");
}
printSpecials(text);
}
代码示例来源:origin: org.activecomponents.jadex/jadex-runtimetools-swing
/**
* Clear the document.
*/
public void clear()
{
try
{
synchronized(doc)
{
doc.remove(0, doc.getLength());
}
}
catch(BadLocationException e)
{
e.printStackTrace();
}
}
代码示例来源:origin: net.sourceforge.jadex/jadex-runtimetools-swing
/**
* Clear the document.
*/
public void clear()
{
try
{
synchronized(doc)
{
doc.remove(0, doc.getLength());
}
}
catch(BadLocationException e)
{
e.printStackTrace();
}
}
代码示例来源:origin: otros-systems/otroslogviewer
@Override
protected void done() {
LOGGER.trace("Message details format and colors calculated, updating GUI");
StyledDocument styledDocument = otrosJTextWithRulerScrollPane.getjTextComponent().getStyledDocument();
try {
styledDocument.remove(0, styledDocument.getLength());
} catch (BadLocationException e) {
LOGGER.error("Can't clear log events text area", e);
}
if (!isCancelled()) {
updateChanges(chunks);
}
LOGGER.trace("GUI updated");
}
代码示例来源:origin: AlexFalappa/nb-springboot
@Override
public void defaultAction(JTextComponent jtc) {
try {
StyledDocument doc = (StyledDocument) jtc.getDocument();
//Here we remove the characters starting at the start offset
//and ending at the point where the caret is currently found:
doc.remove(dotOffset, caretOffset - dotOffset);
doc.insertString(dotOffset, getText(), null);
//This statement will close the code completion box:
Completion.get().hideAll();
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-codegen
private static void removeSectionsBlock (StyledDocument document, ArrayList<SimpleSection> sectionsBlock) {
Position begin = sectionsBlock.get (0).getStartPosition ();
Position end = sectionsBlock.get (sectionsBlock.size () - 1).getEndPosition ();
for (SimpleSection section : sectionsBlock)
section.removeSection ();
try {
document.remove (begin.getOffset (), end.getOffset () - begin.getOffset ());
} catch (BadLocationException e) {
ErrorManager.getDefault ().notify (e);
}
sectionsBlock.clear ();
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base
@Override
public void run () {
try {
doc.remove(0,doc.getLength());
doc.insertString(0,new String(
data,
0,
pos,
FileEncodingQuery.getEncoding(getHandle().resolveFileObject(false))),
null);
} catch (BadLocationException e) {
if (LOG.isLoggable(Level.SEVERE))
LOG.log(Level.SEVERE, e.getMessage(), e);
}
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf
public void run () {
try {
doc.remove(0,doc.getLength());
doc.insertString(0,new String(data,0,pos,encodingName),null);
} catch (BadLocationException e) {
ErrorManager.getDefault().notify(e);
}
catch (UnsupportedEncodingException ee) {
ErrorManager.getDefault().notify (ee);
}
}
});
代码示例来源:origin: org.netbeans.api/org-openide-text
public void run() {
try {
addRemoveDocListener(getDoc(), false);
getDoc().remove(0, getDoc().getLength());
addRemoveDocListener(getDoc(), true);
} catch (BadLocationException ble) {
ERR.log(Level.INFO, null, ble);
}
}
}
代码示例来源:origin: beryx/text-io
public void replaceInput(String message, boolean preserveCaretPosition) {
int oldCaretPosition = textPane.getCaretPosition();
try {
document.remove(startReadLen, document.getLength() - startReadLen);
document.insertString(document.getLength(), message, textPane.getInputAttributes().copyAttributes());
} catch (BadLocationException e) {
e.printStackTrace();
} catch (Exception e) {
logger.error("Cannot insert input text", e);
}
int newCaretPosition = (preserveCaretPosition && oldCaretPosition <= document.getLength()) ? oldCaretPosition : document.getLength();
textPane.setCaretPosition(newCaretPosition);
}
代码示例来源:origin: protegeproject/protege
public void appendToStyledDocument(StyledDocument styledDocument) {
try {
styledDocument.remove(0, styledDocument.getLength());
styledDocument.insertString(0, getString(), null);
for (StyledStringMarkup markup : plainStringMarkup) {
Style style = markup.getStyle();
int length = markup.getEnd() - markup.getStart();
MutableAttributeSet mas = new SimpleAttributeSet();
for (StyleAttribute styleAttribute : style.getStyleAttributes()) {
StyleConstants styleConstants = styleAttribute.getTextAttribute();
Object value = styleAttribute.getTextValue();
mas.addAttribute(styleConstants, value);
}
styledDocument.setCharacterAttributes(markup.getStart(), length, mas, false);
}
}
catch (BadLocationException e) {
e.printStackTrace();
}
}
内容来源于网络,如有侵权,请联系作者删除!