Java 将文本环绕图像
如何在Java中将文本包裹在图像周围?或者如何在Java中实现CSS浮动?
我正在将带有一些图像标签的 HTML 文本加载到 JTextPane 组件中。
示例:
text text text text <img src="image.ext"> text text text
示例2: http://www.bbc.co.uk/news /world-us-canada-11882019 (左侧文本,右侧图像类似)
我需要用文本包裹图像。
尝试使用css...float: right;
(Java不支持该功能..需要它..)
尝试了所有图像对齐方式(左,右等)(没有运气..)
PS PHP程序员..
How to wrap text around an image in Java? Or how to accomplish CSS float in Java?
I am loading a HTML text with some image tags into JTextPane component.
Example:
text text text text <img src="image.ext"> text text text
Example2: http://www.bbc.co.uk/news/world-us-canada-11882019 (text left, image right something similar)
And i need the image to be wrapped with a text.
Tried using css... float: right;
(Java doesn't support that feature.. need it..)
Tried all image alignments(left, right etc.) (no luck..)
P.S. PHP programmer..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关于使用文本组件的 Swing 教程展示了如何使用JEditorPane 用于显示带有图像的 HTML。
The Swing tutorial on Using Text Components, shows how to use a JEditorPane to display HTML with an image.
我已经为 SoftChalk 项目实现了类似的东西(图像和表格周围的文本流)(您可以从 http://softchalk 查看试用版.com/)但这并不是微不足道的。它需要进行大量更改,并花费大量时间来实现并将其嵌入到 HTMLEditorKit 扩展中。
我必须扩展很多视图(BlockView 扩展并完全更改所有可能的容器中的布局行算法 - BODY、DIV、表格单元格、列表项等。
I've implemented something like this (text flow around images and tables) for SoftChalk project (you can see the trial from http://softchalk.com/) but it's not trivial. It required a lot of changes and took significant time to implement and embed this in HTMLEditorKit extension.
I had to extend a lot of views (BlockView extension and completly change layout rows algorithms in all the possible containers - BODY, DIVs, Table cells, list items etc.