开发者

Floating DIVs in a JTextPane

I have an HTML file that I am loading into a JTextPane which contains two DIVs I am trying to show side-by-side (using CSS float). Whatever I try, though, does not work. The instructions element is displayed below the title element, always. I've tried adjusting the widths as well. Does JTextPane not support this CSS property - must I use a table? The file displays correctly in Safari.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <style type="text/css">
            @font-face {
                font-family: Mentone;
                src: local(Mentone),
                    url(Mentone.otf) format("opentype"),
            }

            div#container { width: 95%; margin: 0px auto; }
            div#title { font-family: Mentone; font-size: 108px; width: 200px; margin: 100px 15px 0 15px; float: left; }
            div#instructions { font-family: Mentone; font-size: 130%; width: 300px; margin: 100px 15px 0 15px; color: #dddddd; }
    开发者_C百科    </style>
        <title>Welcome</title>
    </head>
    <body>
        <div id="container">
            <div id="title">my app</div>
            <div id="instructions">Instructions go here.</div>
        </div>
    </body>
</html>


The HTML support in Swing in basic at best and only supports HTML3.2. So it is quite possible what you want to do is not supported.

which contains two DIVs I am trying to show side-by-side (using CSS float).

If you are in control of the HTML, try displaying two separate JTextPanes side by side each containing separate HTML. Both text panes could be added to a panel and the panel added to a scrollpane so they scroll in sync.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜