Codota Logo
DefaultStyledDocument.insertString
Code IndexAdd Codota to your IDE (free)

How to use
insertString
method
in
javax.swing.text.DefaultStyledDocument

Best Java code snippets using javax.swing.text.DefaultStyledDocument.insertString (Showing top 20 results out of 315)

  • Common ways to obtain DefaultStyledDocument
private void myMethod () {
DefaultStyledDocument d =
  • Codota Iconnew DefaultStyledDocument()
  • Codota IconStyleContext styleContext;new DefaultStyledDocument(styleContext)
  • Smart code suggestions by Codota
}
origin: ron190/jsql-injection

@Override
public void insertString(int offs, String str, AttributeSet a)
    throws BadLocationException {
  synchronized (this.docLock) {
    super.insertString(offs, str, a);
    this.color(offs, str.length());
    this.documentReader.update(offs, str.length());
  }
}
origin: stackoverflow.com

 DefaultStyledDocument document = new DefaultStyledDocument();
JTextPane textpane = new JTextPane(document);
StyleContext context = new StyleContext();
// build a style
Style style = context.addStyle("test", null);
// set some style properties
StyleConstants.setForeground(style, Color.BLUE);
// add some data to the document
document.insertString(0, "", style);
origin: org.armedbear.lisp/abcl

protected void superInsertString(int offs, String str, AttributeSet a)
 throws BadLocationException {
 super.insertString(offs, str, a);
}
 
origin: eu.mihosoft.vrl/vrl

  @Override
  public void insertString(int offs, String str, AttributeSet a)
      throws BadLocationException {
    str = str.replaceAll("\t", "    ");
    super.insertString(offs, str, a);
  }
}
origin: org.owasp.jbrofuzz/jbrofuzz

@Override
public void insertString(final int offset, final String str,
    final AttributeSet attr) throws BadLocationException {
  super.insertString(offset, str, attr);
  processChangedLines(offset, str.length());
}
origin: apache/ctakes

 @Override
 public void actionPerformed( final ActionEvent event ) {
   try {
    final int caret = getInsertCaret();
    _piperDocument
       .insertString( caret, "\n// Add a Package that contains Pipe Bits or Piper files\npackage ", null );
   } catch ( BadLocationException blE ) {
    LOGGER.error( blE.getMessage() );
   }
   _runButton.setEnabled( false );
 }
}
origin: apache/ctakes

 @Override
 public void actionPerformed( final ActionEvent event ) {
   try {
    final int caret = getInsertCaret();
    _piperDocument.insertString( caret, "\n// Load a Piper file containing a partial Pipeline\nload ", null );
   } catch ( BadLocationException blE ) {
    LOGGER.error( blE.getMessage() );
   }
   _runButton.setEnabled( false );
 }
}
origin: GoldenGnu/jeveassets

  @Override
  public void insertString(final int offset, final String string, final AttributeSet attributes) throws BadLocationException {
    int length = getLength();
    if (string == null) {
      return;
    }
    if (length + string.length() > maxLength) {
      Toolkit.getDefaultToolkit().beep();
      return;
    }
    super.insertString(offset, string, attributes);
  }
}
origin: apache/ctakes

 @Override
 public void actionPerformed( final ActionEvent event ) {
   try {
    // TODO - hook "set" to the parameter selected in the parameter table.  Can use Value from table.
    // Would require tracking.  Or maybe a constant parse and track of variables set when the formatting is done.
    // Then the "add" button would need to be enabled accordingly ...
    // and the parameter table could display the mapped value.
    final int caret = getInsertCaret();
    _piperDocument.insertString( caret, "\n// Set a global value\nset ", null );
   } catch ( BadLocationException blE ) {
    LOGGER.error( blE.getMessage() );
   }
   _runButton.setEnabled( false );
 }
}
origin: stackoverflow.com

 DefaultStyledDocument doc = new DefaultStyledDocument();
StyleContext sc = new StyleContext();
Style style = sc.addStyle("strikethru", null);
StyleConstants.setStrikeThrough (style,true);
doc.insertString (0, "Hello ", null);
doc.insertString (6, "strike through ", style);
JTextPane pane = new JTextPane(doc);
origin: net.sf.squirrel-sql.thirdparty-non-maven/ostermiller-syntax

public void insertString(int offs, String str, AttributeSet a)
    throws BadLocationException {
  synchronized (docLock) {
    super.insertString(offs, str, a);
    color(offs, str.length());
    documentReader.update(offs, str.length());
  }
}
origin: cmu-phil/tetrad

private void setParseText(String text) {
  try {
    // Add the text to the document
    expressionTextDoc.remove(0, expressionTextPane.getText().length());
    expressionTextDoc.insertString(0, text, null);
  } catch (BadLocationException e) {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}
origin: ontop/ontop

 public void run() {
  try {
   doc.insertString(index, text, style);
   index = index + text.length();
   invalidate();
   repaint();
  }
  catch (BadLocationException e) {
   e.printStackTrace();
  }
 }
});
origin: woder/TorchBot

private void addCom(String text){
   AttributeSet attribute = attributes.get("0");
   try{
     int len = doc.getLength();
     doc.insertString(len, text, attribute);
   }catch (BadLocationException e){
     e.printStackTrace();
   }
   chat.setCaretPosition(chat.getDocument().getLength());
}

origin: apache/ctakes

private void createNewPiper() {
 final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern( "MMMM dd, yyyy" );
 final LocalDate date = LocalDate.now();
 final String text = "//       ***  Piper File  ***\n" +
           "//       Created by " + System.getProperty( "user.name" ) + "\n" +
           "//       on " + date.format( dateFormatter ) + "\n\n";
 try {
   _piperDocument.remove( 0, _piperDocument.getLength() );
   _piperDocument.insertString( 0, text, null );
   _textPane.setCaretPosition( _piperDocument.getLength() );
 } catch ( BadLocationException blE ) {
   LOGGER.warn( blE.getMessage() );
 }
 _runButton.setEnabled( false );
}
origin: zgqq/mah

@Override
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
  setOldState();
  final String origin = getText(0, getLength());
  final int index = StringUtils.getLen(origin, str, maxNumberOfCharacters);
  if (index > 0) {
    super.insertString(offs, str.substring(0, index), a);
  }
}
origin: nu.zoom/base

  public void run()
  {
    Style style = document.getStyle(styleName);
    try {
      document.insertString(
          document.getEndPosition().getOffset() - 1, message,
          style);
    } catch (BadLocationException exc) {
      exc.printStackTrace();
    }
  }
});
origin: org.fudaa.framework.ctulu/ctulu-bu

public void uncolorize() {
 try {
  String text = getText(0, getLength());
  super.remove(0, getLength());
  super.insertString(0, text, null);
 } catch (BadLocationException ex) {}
}
origin: stackoverflow.com

 DefaultStyledDocument document = new DefaultStyledDocument();
JTextPane textpane = new JTextPane(document);
StyleContext context = new StyleContext();
// build a style
Style style = context.addStyle("test", null);
// set some style color
StyleConstants.setForeground(style, Color.RED);
// add some data to the document
document.insertString(0, "", style);


OR




JTextPane pane = new JTextPane();
SimpleAttributeSet set = new SimpleAttributeSet();
StyleConstants.setForeground(set, Color.red);
Document doc = pane.getStyledDocument();
doc.insertString(doc.getLength(), "Kleine ", set);
origin: otros-systems/otroslogviewer

private void updatePatterns() {
 final String text = loggerConfigTextPane.getText();
 final List<LogPattern> resultList = getLogPatterns(text);
 try {
  styledDocument.remove(0, styledDocument.getLength());
  for (LogPattern result : resultList) {
   resultTextPane.insertIcon(result.isValid() ? Icons.STATUS_OK : Icons.STATUS_ERROR);
   styledDocument.insertString(styledDocument.getLength(), " " + result.getPattern() + "\n", defaultStyle);
  }
 } catch (BadLocationException ignore) {
 }
 if (resultList.isEmpty()) {
  resultTextPane.setText("No logger patterns detected in project opened in IDE.");
 }
}
javax.swing.textDefaultStyledDocumentinsertString

Popular methods of DefaultStyledDocument

  • <init>
  • getLength
  • getText
  • remove
  • setCharacterAttributes
  • addDocumentListener
  • setDocumentFilter
  • addUndoableEditListener
  • createPosition
  • getParagraphElement
  • getCharacterElement
  • setParagraphAttributes
  • getCharacterElement,
  • setParagraphAttributes,
  • getDefaultRootElement,
  • insert,
  • addStyle,
  • fireInsertUpdate,
  • fireRemoveUpdate,
  • getEndPosition,
  • getStyle

Popular in Java

  • Updating database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • orElseThrow (Optional)
  • onRequestPermissionsResult (Fragment)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • JFileChooser (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now