问题:
如何在不修改实际查看内容的情况下从HTML格式的JEditorPane获取源代码文本?
我所看到的:
JeditorPane完全能够呈现我的代码,但是无法再次向我展示我之前提供的源代码。
问题:
如果我在JEditorPane中呈现此html代码:
<html>
<head>
<style>
html { font-size: 50%; }
</style>
</head>
<body>
<p>
The font-size property supports a variety of methods for
specifying a font size. For example, there
are seven different absolute size keywords, which set the
font size relative to the user's font size preference.
</p>
<ul>
<li style='font-size: xx-small;'>xx-small</li>
</ul>
<p>
You can also make fonts
<span style='font-size: larger;'>larger</span> or
</p>
<p>
You can make fonts
<span style='font-size: 200%;'>50% larger</span>
or <span style='font-size: 75%;'>25% smaller</span> by way
of percentages.
</p>
<p>
You can even make a font
<span style='font-size: 1.5em;'>50% larger</span>
or <span style='font-size: 0.75em;'>25% smaller</span> by way
of em units.
</p>
</body>
我得到了这个正确的html视图:
但是,如果我使用JEditorPane或文档中的getText()方法,则对源代码进行如下修改:
<html>
<head>
<style type="text/css">
<!--
html { font-size: 50% }
-->
</style>
</head>
<body>
<p>
The font-size property supports a variety of methods for specifying a
font size. For example, there are seven different absolute size
keywords, which set the font size relative to the user's font size
preference.
</p>
<ul>
<li>
xx-small
</li>
</ul>
<p>
You can also make fonts <span><font size="larger">larger</font></span> or
</p>
<p>
You can make fonts <span><font size="200%">50% larger</font></span> or <span><font size="75%">25%
smaller</font></span> by way of percentages.
</p>
<p>
You can even make a font <span><font size="1.5em">50% larger</font></span>
or <span><font size="0.75em">25% smaller</font></span> by way of em
units.
</p>
</body>
</html>
,该代码的视图输出是此WRONG渲染: