这个问题似乎是this one的重复,但实际上并非如此。因此,在回答这个问题之前,请澄清是否有任何混淆。在JTextPane中绘制水平线
我想在我的JTextPane
中的每6-7行之后绘制一条水平线,我正在使用StyledDocument
并在运行时将字符串插入我的JTextPane
。例如:
String myStr = "Some program-generated text";
doc.insertString(doc.getLength(), myStr, attributeSet);
现在如何在每隔几行后绘制一条水平线?我试图
JTextPane textPane = new JTextPane();
textPane.setContentType("text/html");
textPane.setText("<html>Some Text Above The Line<hr size=5>Some Text Below</html>");
但目前我的应用程序使用setContentType("text/plain");
其更改为Text.html
扰乱整个UI。此外,如果我使用SetText()
那么它将被作为新鲜的文本插入,所有以前的文本将消失,我附加了doc.insertString();
任何帮助将不胜感激。
你能告诉我怎么称呼它吗? – 2014-08-28 04:50:41