[英]Java GUI with scrolling text and images
How do I create a GUI with a scrolling text area and underneath small paragraphs of text there are corresponding images? 如何创建带有滚动文本区域的GUI,在文本的小段下面有相应的图像?
I am currently using a JTextArea
with a scroll-bar to display the text and it works great, but I want to display the corresponding images underneath each small paragraph of text. 我目前正在使用带有滚动条的
JTextArea
来显示文本,并且效果很好,但是我想在文本的每个小段落下显示相应的图像。
You can use javax.swing.JTextPane 您可以使用javax.swing.JTextPane
Check TextSamplerDemo 检查TextSamplerDemo
You can find plenty of examples here: 您可以在此处找到很多示例:
http://www.java2s.com/Code/Java/Swing-JFC/TextPaneSample.htm http://www.java2s.com/Code/Java/Swing-JFC/TextPaneSample.htm
最简单的方法是将JEditorPane
与HTMLEditorKit
使用。您可以像网页一样使用HTML文本格式的表单,包括图形。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.