0
은 가정하자 나는 JTextArea
하고 난 특정 텍스트로 현재 행을 교체하려면 :JTextArea - 현재 행의 첫 번째 색인을 얻는 방법?
예
123
123455
68967869
gh
지금은 현재 커서 기존 라인의 텍스트를 대체합니다.
그래서 3 번째 줄에 커서가 출력이됩니다 경우 :123
123455
replaced text
gh
지금 나는이 코드가 있습니다. 그러나 현재 줄의 첫 번째 위치가 아닌 현재 줄에 추가됩니다.
jtextarea1.getDocument().insertString(jtextarea1.getCaretPosition(), "replaced text", null);
출력
123
123455
68967869replaced text//that's the problem
gh
왜 http://docs.oracle.com/javase/8 (['JTextArea']에 연결하지 /docs/api/javax/swing/JTextArea.html) (최신 문서)? –
고마워요.하지만 제 2 줄에 오류가 있습니다. –
@whiletrue 실수를 수정했습니다. –