가 아닌 HTMLEditorKit가 설치된 JEditorPane.getText()를 사용할 때 불일치를 해결하려고합니다.HTMLEditorKit를 사용하는 JEditorPane가 <br> 태그 대신
JEditorPane.setText를 사용하여 < br> 태그가 포함 된 HTML 문자열을 전달할 수 있으며 getText()를 사용하면 해당 줄 바꿈이 < br>와 올바르게 표시됩니다. 그러나 사용자가 JEditorPane에 개행을 입력하면 getText()는 < br> 태그 대신 "/ n"문자를 반환합니다. 내 사용자 정의 HTML 파서는 사용자 "/ n"문자와 "/ n"문자를 뚜렷하게 구분할 수 없으며 HTML 문자열을보기 좋게 만듭니다. 예 : 사용자가 텍스트를 입력하면
는 JEditorPane.getText() 절차는 다음과 같이 뭔가를 반환합니다
<html>
<head>
</head>
<body>
I've written some text! Indeed so much text that this line is probably
going to word wrap when I run the getText procedure!
And now I just hit enter a few times! I wonder what will happen if it wraps
another time? WHAM.
And I'll hit enter once more for good measure.
</body>
</html>
내가로 표시하려면이 옵션을 기대할 수있는 반면 :
<html>
<head>
</head>
<body>
I've written some text! Indeed so much text that this line is probably
going to word wrap when I run the getText procedure!<br><br>And now I
just hit enter a few times! I wonder what will happen if it wraps
another time? WHAM.<br>And I'll hit enter once more for good measure.
</body>
</html>
< br> 사용자가 Enter 키를 눌렀을 때 getText 문자열에 삽입 할 수있는 방법이 있습니까? 내 첫 번째 시도는 documentFilter를 사용하는 것이지만 문서에서는 필자가 필터 내에서 insertString 또는 filterBypass를 사용하는 것으로되어 있으므로 setText ("< br>") 경로를 사용할 수 없습니다. 읽은 톤 후, 나는 HTMLEditorKit을 확장하고 읽기 절차를 무시하는 또 다른 옵션이 될 것이라고 생각하고 있습니까? JTextComponents는 내게 새 것이므로 내 머리 위로 그 방법이 있습니다. 다른 옵션이 있습니까? 아니면 자원?
감사합니다.
문제를 설명하기 위해 SSCCE를 게시 하시겠습니까? – StanislavL