### Get Current Line

Getting the current line, have not found a good solution yet, but below works so far so good using a JavaObject.
If JAVA
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
/*
• Return the line number at the Caret position.
• (Replace TextArea below by the TextArea defined)
• Usage B4J:
• Dim joTA As JavaObject = TextArea
• Dim cursorpos As Int = joTA.RunMethod("getCaretPosition", Null)
• Dim linepos As Int = joInline.RunMethod("getLineAtCaret", Array(TextArea.Text, cursorpos))
*/
public static int getLineAtCaret(String content, int caretpos)
{
int linenum = -1;
JTextArea editArea = new JTextArea(content);
try {
linenum = editArea.getLineOfOffset(caretpos);
linenum += 1;
}
catch(Exception ex) { }
return linenum;
}
End If

Changed: , Category: TextArea, File: T6C261M1925.htm, ID: 1925