【发布时间】:2014-11-07 17:48:57
【问题描述】:
我正在使用 JEditorPane 来显示一些包含 HTML 标记的文本,
JEditorPane htmlTextPane = new JEditorPane();
htmlTextPane.setContentType("text/html");
htmlTextPane.setText("This text pane contains html. The custom HTMLEditorKit supports single letter wrapping.");
final JScrollPane editorScrollPane = new JScrollPane(htmlTextPane);
editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
editorScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
当我启动应用程序时,text/html 似乎可以正确换行,但是当我尝试在运行时设置 JEditorPane 的值时(例如单击表格行,会得到 html 文本)调用JEditorPane.setText("some html text"),新文本无法换行,我看不到整个文本。
【问题讨论】:
标签: java html swing user-interface word-wrap