javax.swing.JTextArea.getLineEndOffset()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(165)

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

JTextArea.getLineEndOffset介绍

暂无

代码示例

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

for (int line = 0; line < textArea.getLineCount(); line++) {
  int start = textArea.getLineStartOffset(line);
  int end = textArea.getLineEndOffset(line);
  String lineText = textArea.getText(start, end - start);
  if (lineText.endsWith("\n")) {

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

int endIndex = tarea.getLineEndOffset(lineNumber);
String colour = (String) cbox.getSelectedItem();

代码示例来源:origin: org.apache.jmeter/jorphan

public String[] getTextLines() {
    int numLines = mTextArea.getLineCount();
    String[] lines = new String[numLines];
    for(int i = 0; i < numLines; i++) {
      try {
        int start = mTextArea.getLineStartOffset(i);
        int end = mTextArea.getLineEndOffset(i); // treats last line specially
        if (i == numLines-1) { // Last line
          end++; // Allow for missing terminator
        }
        lines[i]=mTextArea.getText(start, end-start-1);
      } catch (BadLocationException e) { // should not happen
        throw new IllegalStateException("Could not read line "+i,e);
      }
    }
    return lines;
  }
}

代码示例来源:origin: java-deobfuscator/deobfuscator-gui

@Override
  public void write(int b) throws IOException 
  {
    console.append(String.valueOf((char)b));
    if(shouldLimitLines.isSelected() && console.getLineCount() > 100)
    {
      try
      {
        console.replaceRange("", 0, console.getLineEndOffset(0));
      }catch(Exception e)
      {
        
      }
    }
  }
}

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

try
  inputTextArea.scrollRectToVisible(inputTextArea.modelToView(inputTextArea.getLineEndOffset(inputTextArea.getLineCount())));
  inputTextArea.setCaretPosition(inputTextArea.getLineEndOffset(inputTextArea.getLineCount()));

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

private void selectCurrentLine(int x, int y) {
  // This is just temporary placeholder code
  int ln = ta.getLineCount(); 
  if (ln > 0) {
    try {
      selected_area_start = ta.getLineStartOffset(ln);
      selected_area_end = ta.getLineEndOffset(ln);
      ta.select(selected_area_start, selected_area_end);
    } catch (javax.swing.text.BadLocationException e) {
      //selected_area_start = 0;
      //selected_area_end = 0;
    }
  }
}

代码示例来源:origin: sundapeng/FinalSpeed

public void trunkTextArea(JTextArea txtWin){
  int numLinesToTrunk = txtWin.getLineCount() - SCROLL_BUFFER_SIZE;
  if(numLinesToTrunk > 0)
  {
    try
    {
      int posOfLastLineToTrunk = txtWin.getLineEndOffset(numLinesToTrunk - 1);
      txtWin.replaceRange("",0,posOfLastLineToTrunk);
    }
    catch (BadLocationException ex) {
      ex.printStackTrace();
    }
  }
}

代码示例来源:origin: org.geotools/gt-swing

for (int line = 0; line < textArea.getLineCount(); line++) {
  int start = textArea.getLineStartOffset(line);
  int end = textArea.getLineEndOffset(line);
  String lineText = textArea.getText(start, end - start);
  if (lineText.endsWith("\n")) {

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

final int SCROLL_BUFFER_SIZE = 100;
public void trunkTextArea(JTextArea txtWin)
{
  int numLinesToTrunk = txtWin.getLineCount() - SCROLL_BUFFER_SIZE;
  if(numLinesToTrunk > 0)
  {
    try
    {
      int posOfLastLineToTrunk = txtWin.getLineEndOffset(numLinesToTrunk - 1);
      txtWin.replaceRange("",0,posOfLastLineToTrunk);
    }
    catch (BadLocationException ex) {
      ex.printStackTrace();
    }
  }
}

代码示例来源:origin: org.owasp.jbrofuzz/jbrofuzz

/**
   * <p>Write output to the console of the Graphing Panel.</p>
   * 
   * @param input
   */
  public void toConsole(final String input) {

    // Use a FILO for the output to the console, never exceeding 500 lines
    if (console.getLineCount() > 500) {
      try {
        console.select(console.getLineStartOffset(0), console
            .getLineEndOffset(console.getLineCount() - 500));
        console.replaceSelection("...\n");
      } catch (final BadLocationException e) {
        Logger.log("Could not clear the console", 3);
      }
    }

    console.append("> " + input + "\n");
    console.setCaretPosition(console.getText().length());

  }
}

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

JTextArea txt = ...;
int caretOffset = txt.getCaretPosition();
int lineNumber = txt.getLineOfOffset(caretOffset);
int startOffset = txt.getLineStartOffset(lineNumber);
int endOffset = txt.getLineEndOffset(lineNumber);

txt.replaceRange("Replaced Text", startOffset, endOffset);

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

try {
  int start = text.getLineStartOffset(i);
  int length = text.getLineEndOffset(i) - start;
  list.add(doc.getText(start, length));
} catch (BadLocationException ex) {

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

lineEnd = textarea.getLineEndOffset(lineNumber);
strText = textarea.getText(lineStart, lineEnd-lineStart);
} catch( Exception exception)

代码示例来源:origin: eu.mihosoft.vrl/vrl

int len = editor.getLineEndOffset(l) - offset;
  uncommentedLines.add(l);
  line = line.replaceFirst("\\/\\/", "");
  editor.replaceRange(line, offset, editor.getLineEndOffset(l));

代码示例来源:origin: jpos/jPOS

public void run () {
  if (ui.isDestroyed ()) {
    logger.removeListener (this);
    text.setText ("");
    return;
  }
  int lc = text.getLineCount ();
  if (lc > maxLines) {
    try {
      int startOffset = text.getLineStartOffset (maxLines);
      int endOffset = text.getLineEndOffset(lc-1);
      text.getDocument ().remove (startOffset, endOffset-startOffset);
    } catch (BadLocationException ex) {
      text.setText (ex.toString());
    }
  }
}
public LogEvent log (LogEvent evt) {

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

int end =    textArea.getLineEndOffset(1);
highlighter.addHighlight(start, end, painter );

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

try {
  int startPos = ta.getLineStartOffset(line - 1);
  int endPos = ta.getLineEndOffset(line - 1);
  Document doc = ta.getDocument();

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

lineEnd = textarea.getLineEndOffset(lineNumber);
  strText = textarea.getText(lineStart, lineEnd - lineStart);
} catch (Exception exception) {

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

for (int i = 0; i < area.getLineCount(); i++) {
  try {
    int endOffset = area.getLineEndOffset(i);
    int lineSize = endOffset - startOffset;
    if (lineSize > maxColumns) {

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

int lineNumber = area.getLineOfOffset(caretOffset);
  int startOffset = area.getLineStartOffset(lineNumber);
  int endOffset = area.getLineEndOffset(lineNumber);
  int offset = ta.getLineOfOffset(ta.getCaretPosition());
  int start = ta.getLineStartOffset(offset);
  int end = ta.getLineEndOffset(offset);
  text = ta.getText(start, (end - start));
} catch (BadLocationException ex) {

相关文章

JTextArea类方法