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

x33g5p2x  于2022-01-15 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(127)

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

AbstractDocument.getText介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

super.insertString(offset, str, a);
String text = getText(0, getLength());
int before = findLastNonWordChar(text, offset);
if (before < 0) before = 0;
super.remove(offs, len);
String text = getText(0, getLength());
int before = findLastNonWordChar(text, offs);
if (before < 0) before = 0;

代码示例来源:origin: ron190/jsql-injection

/**
 * Read a single character.
 *
 * @return the character or -1 if the end of the document has been reached.
 */
@Override
public int read(){
  if (this.position < this.document.getLength()){
    try {
      char c = this.document.getText((int)this.position, 1).charAt(0);
      this.position++;
      return c;
    } catch (BadLocationException e){
      // Ignore
      IgnoreMessageException exceptionIgnored = new IgnoreMessageException(e);
      LOGGER.trace(exceptionIgnored, exceptionIgnored);
      return -1;
    }
  } else {
    return -1;
  }
}

代码示例来源:origin: ron190/jsql-injection

String s = this.document.getText((int)this.position, length);
this.position += length;
for (int i=0; i<length; i++){

代码示例来源:origin: net.sf.jt400/jt400

/**
Stores the text contained within the specified portion of
the document in a segment.

@param offset   The offset into the document representing
        the desired start of the text.
@param length   The length of the text.
@param text     The segment in which to store the text.

@exception      BadLocationException    If the given offset and length does
                    not represent a valid range in the
                    document.
**/
  public synchronized void getText (int offset, int length, Segment text)
    throws BadLocationException
  {
    document_.getText (offset, length, text);
  }

代码示例来源:origin: net.sf.jt400/jt400

/**
Returns the text contained within the specified portion of
the document.

@param offset   The offset into the document representing
        the desired start of the text.
@param length   The length of the text.
@return         The text.

@exception      BadLocationException    If the given offset and length does
                    not represent a valid range in the
                    document.
**/
  public synchronized String getText (int offset, int length)
    throws BadLocationException
  {
    return document_.getText (offset, length);
  }

代码示例来源:origin: net.sf.jt400/jt400

/**
Stores the text contained within the specified portion of
the document in a segment.

@param offset   The offset into the document representing
        the desired start of the text.
@param length   The length of the text.
@param text     The segment in which to store the text.

@exception      BadLocationException    If the given offset and length does
                    not represent a valid range in the
                    document.
**/
  public synchronized void getText (int offset, int length, Segment text)
    throws BadLocationException
  {
    document_.getText (offset, length, text);
  }

代码示例来源:origin: net.sf.jt400/jt400

/**
Returns the text contained within the specified portion of
the document.

@param offset   The offset into the document representing
        the desired start of the text.
@param length   The length of the text.
@return         The text.

@exception      BadLocationException    If the given offset and length does
                    not represent a valid range in the
                    document.
**/
  public synchronized String getText (int offset, int length)
    throws BadLocationException
  {
    return document_.getText (offset, length);
  }

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

/**
 * Read a single character.
 *
 * @return the character or -1 if the end of the document has been reached.
 */
public int read(){
  if (position < document.getLength()){
    try {
      char c = document.getText((int)position, 1).charAt(0);
      position++;
      return c;
    } catch (BadLocationException x){
      return -1;
    }
  } else {
    return -1;
  }
}

代码示例来源:origin: stackoverflow.com

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.text.AttributeSet;
import javax.swing.text.PlainDocument;

/**
*
* @author cpp-qt
*/
public class HexDocument extends PlainDocument {

private String text = "";

@Override
public void insertString(int offset, String txt, AttributeSet a) {
  try {
    text = getText(0, getLength());
    if ((text + txt).matches("[0-9a-fA-F]{0,7}")) {
      super.insertString(offset, txt, a);
    }
   } catch (Exception ex) {
    Logger.getLogger(HexDocument.class.getName()).log(Level.SEVERE, null, ex);
   }

  }
}

代码示例来源:origin: stackoverflow.com

int val = Integer.parseInt(getText(0,offs));
if (val == 0)

代码示例来源:origin: stackoverflow.com

break;
} else {
  if(this.getText(0, this.getLength()).contains(".")){
    isValid = false;
    break;

代码示例来源:origin: stackoverflow.com

String text = abstractDocument.getText(0, abstractDocument.getLength());
int newLength = text.length() + inputLength;

代码示例来源:origin: stackoverflow.com

String currText = getText(0, getLength());
StringBuilder b = new StringBuilder(currText);
b.insert(offs, str);

代码示例来源:origin: stackoverflow.com

Element line = doc.getParagraphElement(offset);
int lineStart = line.getStartOffset(), lineEnd = line.getEndOffset();
String content = doc.getText(lineStart, lineEnd - lineStart);
int start = 0;
while(content.charAt(start)==' ') {

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

String s = document.getText((int)position, length);
position += length;
for (int i=0; i<length; i++){

代码示例来源:origin: net.sf.tinylaf/tinylaf

String text = getText(0, getLength());

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

@Override
public int getOffsetOfDeepestStatementLocationAtPos( int caretPosition, boolean strict )
{
 Element root = getDocument().getDefaultRootElement();
 int iElem = root.getElementIndex( caretPosition );
 if( iElem < 0 )
 {
  return -1;
 }
 Element elem = root.getElement( iElem );
 try
 {
  int lineStart = elem.getStartOffset();
  int lineEnd = elem.getEndOffset();
  String text = getDocument().getText( lineStart, lineEnd - lineStart );
  String trimmed = text.trim();
  int whitespace = text.indexOf( trimmed );
  if( whitespace == text.length() )
  {
   // all whitespace
   return -1;
  }
  // location of first non-whitespace char in line
  return lineStart + whitespace;
 }
 catch( BadLocationException e )
 {
  throw new RuntimeException( e );
 }
}

代码示例来源:origin: stackoverflow.com

PlainDocument doc = ((PlainDocument)e.getDocument());
try {
  String value = doc.getText(0, doc.getLength());
  changed = originalValue == null || !originalValue.equals(value);
} catch(BadLocationException exc) {

代码示例来源:origin: net.sf.jt400/jt400

/**
Writes the contents of the document to the data queue.The entry replaces the current content. System and path must be set prior
to calling this method.
**/
  public void write ()
  {
    workingEventSupport_.fireStartWorking ();

    // Write the contents.
    try {
      dataQueue_.write (document_.getText (0, document_.getLength ()));
    }
    catch (Exception e) {
      errorEventSupport_.fireError (e);
    }

    workingEventSupport_.fireStopWorking ();
  }

代码示例来源:origin: net.sf.jt400/jt400

/**
Writes the contents of the document to the data queue.The entry replaces the current content. System and path must be set prior
to calling this method.

@param key  The string that contains the key for this entry.
**/
  public void write (String key)
  {
    workingEventSupport_.fireStartWorking ();

    // Write the contents.
    try {
      dataQueue_.write (key, document_.getText (0, document_.getLength ()));
    }
    catch (Exception e) {
      errorEventSupport_.fireError (e);
    }

    workingEventSupport_.fireStopWorking ();
  }

相关文章