javax.swing.text.StyledDocument.remove()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中javax.swing.text.StyledDocument.remove()方法的一些代码示例,展示了StyledDocument.remove()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StyledDocument.remove()方法的具体详情如下:
包路径:javax.swing.text.StyledDocument
类名称:StyledDocument
方法名:remove

StyledDocument.remove介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

  1. @Override
  2. public void run() {
  3. try {
  4. int documentOffset = sourceOffset;
  5. document.remove(documentOffset, caretOffset - documentOffset);
  6. document.insertString(documentOffset, text, null);
  7. } catch (BadLocationException ex) {
  8. }
  9. }
  10. });

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

  1. public void run() {
  2. try {
  3. doc.removeDocumentListener(getListener());
  4. doc.remove(0, doc.getLength()); // remove all text
  5. doc.addDocumentListener(getListener());
  6. } catch(BadLocationException ble) {
  7. ErrorManager.getDefault().notify(
  8. ErrorManager.INFORMATIONAL, ble);
  9. }
  10. }
  11. });

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf

  1. @Override
  2. public void run() {
  3. try {
  4. doc.remove(0, passPrologLen + 1); // +1 it removes exclusive
  5. doc.insertString(0, "<?xml version='1.0' encoding='UTF-8' ?> \n<!-- was: " + new String(prolog, 0, passPrologLen + 1) + " -->", null); // NOI18N
  6. } catch (BadLocationException e) {
  7. if (System.getProperty("netbeans.debug.exceptions") != null) { // NOI18N
  8. Exceptions.printStackTrace(e);
  9. }
  10. }
  11. }
  12. };

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

  1. public void run() {
  2. try {
  3. doc.removeDocumentListener(getListener());
  4. doc.remove(0, doc.getLength()); // remove all text
  5. doc.addDocumentListener(getListener());
  6. } catch(BadLocationException ble) {
  7. ErrorManager.getDefault().notify(
  8. ErrorManager.INFORMATIONAL, ble);
  9. }
  10. }
  11. });

代码示例来源:origin: Vhati/Slipstream-Mod-Manager

  1. public void clear() {
  2. try {
  3. doc.remove( 0, doc.getLength() );
  4. }
  5. catch ( BadLocationException e ) {
  6. log.error( "Error clearing info text area", e );
  7. }
  8. }

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

  1. void clear() {
  2. try {
  3. styledDoc.remove(0, styledDoc.getLength());
  4. } catch (BadLocationException ble1) {
  5. System.err.println("View.clear(): Couldn't remove initial text from document.");
  6. }
  7. }

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-jboss4

  1. public void run() {
  2. try {
  3. doc.remove(0, doc.getLength());
  4. doc.insertString(0, out.toString(), null);
  5. } catch (BadLocationException ble) {
  6. Exceptions.printStackTrace(ble);
  7. }
  8. }
  9. });

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-tomcat5

  1. public void run() {
  2. try {
  3. doc.remove(0, doc.getLength());
  4. doc.insertString(0, out.toString(), null);
  5. } catch (BadLocationException ble) {
  6. Exceptions.printStackTrace(ble);
  7. }
  8. }
  9. });

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-core

  1. public void run() {
  2. try {
  3. doc.remove(0, passPrologLen + 1); // +1 it removes exclusive
  4. doc.insertString(0, "<?xml version='1.0' encoding='UTF-8' ?> \n<!-- was: " + new String(prolog, 0, passPrologLen + 1) + " -->", null); // NOI18N
  5. } catch (BadLocationException e) {
  6. if (System.getProperty("netbeans.debug.exceptions") != null) // NOI18N
  7. e.printStackTrace();
  8. }
  9. }
  10. };

代码示例来源:origin: chatty/chatty

  1. /**
  2. * Set this text pane to a new text. Removes any previous content and adds
  3. * the new text while adding clickablel links.
  4. *
  5. * @param text
  6. */
  7. @Override
  8. public void setText(String text) {
  9. try {
  10. doc.remove(0, doc.getLength());
  11. } catch (BadLocationException ex) {
  12. LOGGER.warning("Bad location");
  13. }
  14. printSpecials(text);
  15. }

代码示例来源:origin: org.activecomponents.jadex/jadex-runtimetools-swing

  1. /**
  2. * Clear the document.
  3. */
  4. public void clear()
  5. {
  6. try
  7. {
  8. synchronized(doc)
  9. {
  10. doc.remove(0, doc.getLength());
  11. }
  12. }
  13. catch(BadLocationException e)
  14. {
  15. e.printStackTrace();
  16. }
  17. }

代码示例来源:origin: net.sourceforge.jadex/jadex-runtimetools-swing

  1. /**
  2. * Clear the document.
  3. */
  4. public void clear()
  5. {
  6. try
  7. {
  8. synchronized(doc)
  9. {
  10. doc.remove(0, doc.getLength());
  11. }
  12. }
  13. catch(BadLocationException e)
  14. {
  15. e.printStackTrace();
  16. }
  17. }

代码示例来源:origin: otros-systems/otroslogviewer

  1. @Override
  2. protected void done() {
  3. LOGGER.trace("Message details format and colors calculated, updating GUI");
  4. StyledDocument styledDocument = otrosJTextWithRulerScrollPane.getjTextComponent().getStyledDocument();
  5. try {
  6. styledDocument.remove(0, styledDocument.getLength());
  7. } catch (BadLocationException e) {
  8. LOGGER.error("Can't clear log events text area", e);
  9. }
  10. if (!isCancelled()) {
  11. updateChanges(chunks);
  12. }
  13. LOGGER.trace("GUI updated");
  14. }

代码示例来源:origin: AlexFalappa/nb-springboot

  1. @Override
  2. public void defaultAction(JTextComponent jtc) {
  3. try {
  4. StyledDocument doc = (StyledDocument) jtc.getDocument();
  5. //Here we remove the characters starting at the start offset
  6. //and ending at the point where the caret is currently found:
  7. doc.remove(dotOffset, caretOffset - dotOffset);
  8. doc.insertString(dotOffset, getText(), null);
  9. //This statement will close the code completion box:
  10. Completion.get().hideAll();
  11. } catch (BadLocationException ex) {
  12. Exceptions.printStackTrace(ex);
  13. }
  14. }

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-codegen

  1. private static void removeSectionsBlock (StyledDocument document, ArrayList<SimpleSection> sectionsBlock) {
  2. Position begin = sectionsBlock.get (0).getStartPosition ();
  3. Position end = sectionsBlock.get (sectionsBlock.size () - 1).getEndPosition ();
  4. for (SimpleSection section : sectionsBlock)
  5. section.removeSection ();
  6. try {
  7. document.remove (begin.getOffset (), end.getOffset () - begin.getOffset ());
  8. } catch (BadLocationException e) {
  9. ErrorManager.getDefault ().notify (e);
  10. }
  11. sectionsBlock.clear ();
  12. }

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

  1. @Override
  2. public void run () {
  3. try {
  4. doc.remove(0,doc.getLength());
  5. doc.insertString(0,new String(
  6. data,
  7. 0,
  8. pos,
  9. FileEncodingQuery.getEncoding(getHandle().resolveFileObject(false))),
  10. null);
  11. } catch (BadLocationException e) {
  12. if (LOG.isLoggable(Level.SEVERE))
  13. LOG.log(Level.SEVERE, e.getMessage(), e);
  14. }
  15. }
  16. });

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf

  1. public void run () {
  2. try {
  3. doc.remove(0,doc.getLength());
  4. doc.insertString(0,new String(data,0,pos,encodingName),null);
  5. } catch (BadLocationException e) {
  6. ErrorManager.getDefault().notify(e);
  7. }
  8. catch (UnsupportedEncodingException ee) {
  9. ErrorManager.getDefault().notify (ee);
  10. }
  11. }
  12. });

代码示例来源:origin: org.netbeans.api/org-openide-text

  1. public void run() {
  2. try {
  3. addRemoveDocListener(getDoc(), false);
  4. getDoc().remove(0, getDoc().getLength());
  5. addRemoveDocListener(getDoc(), true);
  6. } catch (BadLocationException ble) {
  7. ERR.log(Level.INFO, null, ble);
  8. }
  9. }
  10. }

代码示例来源:origin: beryx/text-io

  1. public void replaceInput(String message, boolean preserveCaretPosition) {
  2. int oldCaretPosition = textPane.getCaretPosition();
  3. try {
  4. document.remove(startReadLen, document.getLength() - startReadLen);
  5. document.insertString(document.getLength(), message, textPane.getInputAttributes().copyAttributes());
  6. } catch (BadLocationException e) {
  7. e.printStackTrace();
  8. } catch (Exception e) {
  9. logger.error("Cannot insert input text", e);
  10. }
  11. int newCaretPosition = (preserveCaretPosition && oldCaretPosition <= document.getLength()) ? oldCaretPosition : document.getLength();
  12. textPane.setCaretPosition(newCaretPosition);
  13. }

代码示例来源:origin: protegeproject/protege

  1. public void appendToStyledDocument(StyledDocument styledDocument) {
  2. try {
  3. styledDocument.remove(0, styledDocument.getLength());
  4. styledDocument.insertString(0, getString(), null);
  5. for (StyledStringMarkup markup : plainStringMarkup) {
  6. Style style = markup.getStyle();
  7. int length = markup.getEnd() - markup.getStart();
  8. MutableAttributeSet mas = new SimpleAttributeSet();
  9. for (StyleAttribute styleAttribute : style.getStyleAttributes()) {
  10. StyleConstants styleConstants = styleAttribute.getTextAttribute();
  11. Object value = styleAttribute.getTextValue();
  12. mas.addAttribute(styleConstants, value);
  13. }
  14. styledDocument.setCharacterAttributes(markup.getStart(), length, mas, false);
  15. }
  16. }
  17. catch (BadLocationException e) {
  18. e.printStackTrace();
  19. }
  20. }

相关文章