1
JEditorPane
에 HTML을 추가하고 싶지만 텍스트가 올바르게 표시되지 않습니다. 또한 텍스트의 높이가 편집기의 높이 인 보다 커서 커서가 스크롤 창의 마지막 줄로 이동합니다.Java의 JEditorPane에 HTML 추가 Swing
JPanel JPInfo = new JPanel(new BorderLayout());
JPInfo.setBorder(BorderFactory.createTitledBorder("Information"));
editorPaneInfo = new JEditorPane();
editorPaneInfo.setEditable(false);
editorPaneInfo.setText("<html><p style=\"color:green\"> Test Test </p></html>");
JScrollPane editorScrollPaneInfo = new JScrollPane(editorPaneInfo);
editorScrollPaneInfo.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
JPInfo.add(editorScrollPaneInfo,BorderLayout.CENTER);
해결 :
내가 다음 줄을 추가 : 나는editorPaneInfo.setContentType("text/html");
1) 더 빨리 도움을 받으려면 [SSCCE] (http://sscce.org/)를 게시하십시오. 2) a) 일어날 것으로 예상되는 것 b) 실제로 일어난 일과 효용 c) 왜 (a) 일어날 것으로 예상했는지 설명하십시오. 스크린 샷이 도움이 될 수 있습니다. –
텍스트가 녹색으로 표시 될 것으로 예상했지만 문제가 해결되었습니다. 다음 링크를 방문했습니다. [http://stackoverflow.com/questions/5174070/wrapping-html-text-in-a-jeditorpane-inside-a- jscrollpane] 그리고'editorPaneInfo.setContentType ("text/html");을 추가했습니다. 이제는 모든 것이 작동합니다! – programmer
질문에 답하거나 삭제하십시오. –