java点击一次按钮 在面板上增加一个JTextAreaJTextArea往下一次排好

java点击一次按钮 在面板上增加一个JTextAreaJTextArea往下一次排好,第1张

滚动条是用的

JScrollPane name = new JScrollPane(监控控件的名字)

然后把scrollPane add 到和要监控的相同的位置。。

刷新试试楼上的实在不行就

setVisible(false)

setVisible(true)

应该可以刷新。。但这个方法笨了一点。。。。

JTextArea 对应于 PlainDocument, 不支持 插入图片之类Rich Text。

想插入图片需要使用JTextPane。

1

2

3

4

5

6

7

JTextPane textPane = new JTextPane()

StyledDocument doc = (StyledDocument) textPane.getDocument()

Style style = doc.addStyle("StyleName", null)

StyleConstants.setIcon(style, new ImageIcon("imagefile"))

doc.insertString(doc.getLength(), "ignored text", style)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/7932001.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-11
下一篇2023-04-11

发表评论

登录后才能评论

评论列表(0条)

    保存