Displaying html in Swing

I have downloaded a weather sticker from weatherbug. If I use it in an html page, it works fine. If I use the following code to put it in a swing frame, it does not. What I am doing incorrectly?
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import java.io.IOException;
public class HtmlTest extends JPanel {
    /** Creates a new instance of HtmlTest */
    public HtmlTest() {
        //String htmlText = "<link rel='stylesheet' type='text/css' media='screen' title='160x600_v2' href='http://img.weather.weatherbug.com/Style/stickers/v2/Stickers_160x600.css' /><div class='wXbody'><div class='headerlogo'><a href='http://weather.weatherbug.com/default.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather.html?zcode=z5545&units=0''><img src='http://img.weather.weatherbug.com/images/stickers/v2/160x600/top-wxbug-logo.jpg' border='0' alt='WeatherBug' /></a></div><iframe id='WeatherBugSticker_160x600_v2' src='http://weather.weatherbug.com/desktop-weather/getSticker.html?ZipCode=47872&ZCode=z5545&Size=160x600&StationID=ROCKS&units=0&Version=2' width='146' height='296' frameborder='0' scrolling='no' allowtransparency='yes'></iframe><div class='wXlinks'><span class='link'><a href='http://weather.weatherbug.com/weather-forecast.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather/local-forecast/7-day-forecast.html?zcode=z5545&units=0''>Forecast</a></span><br /><br /><span class='link'><a href='http://weather.weatherbug.com/doppler-radar.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather/local-radar/doppler-radar.html?zcode=z5545&units=0''>Radar</a></span><br /><br /><span class='link'><a href='http://community-weather.weatherbug.com/community/weather-photos/photo-gallery.html' target='_blank' onclick='Javascript:this.href='http://community-weather.weatherbug.com/community/weather-photos/photo-gallery.html?zcode=z5545&units=0&zip=47872''>Photos</a></span></div><div class='wXlinks2'><span class='link'><a href='http://weather.weatherbug.com/weather-cams.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather/weather-cams/local-cams.html?zcode=z5545&units=0''>Cameras</a></span><br /><br /><span class='link'><a href='http://weather.weatherbug.com/weather-reports.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/weather-reports.html?zcode=z5545&units=0&zip=47872''>News</a></span><br /><br /><span class='link'><a href='http://weather.weatherbug.com/travel-forecast.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/travel-forecast.html?zcode=z5545&units=0&zip=47872''>Travel</a></span></div><div class='footer'><a href='http://weather.weatherbug.com/default.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather.html?zcode=z5545&units=0''><img src='http://img.weather.weatherbug.com/images/stickers/v2/160x600/local.jpg' border='0' alt='WeatherBug' /></a><br /><a href='http://weather.weatherbug.com/default.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather.html?zcode=z5545&units=0''><img src='http://img.weather.weatherbug.com/images/stickers/v2/160x600/bt-wxbug-logo.jpg' border='0' id='logo' alt='WeatherBug' /></a><br /><div class='footertext'>Your weather just got better.</div></div>";   
           String htmlText="<html><link rel='stylesheet' type='text/css' media='screen' title='160x600_v2' href='http://img.weather.weatherbug.com/Style/stickers/v2/Stickers_160x600.css' />" + 
           "<div class='wXbody'>" +
            "<div class='headerlogo'>" +
            "<a href='http://weather.weatherbug.com/default.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather.html?zcode=z5545&units=0''><img src='http://img.weather.weatherbug.com/images/stickers/v2/160x600/top-wxbug-logo.jpg' border='0' alt='WeatherBug' /></a></div>" +
            "<iframe id='WeatherBugSticker_160x600_v2' src='http://weather.weatherbug.com/desktop-weather/getSticker.html?ZipCode=47872&ZCode=z5545&Size=160x600&StationID=ROCKS&units=0&Version=2' width='146' height='296' frameborder='0' scrolling='no' allowtransparency='yes'></iframe>" +
            "<div class='wXlinks'>" +
            "<span class='link'><a href='http://weather.weatherbug.com/weather-forecast.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather/local-forecast/7-day-forecast.html?zcode=z5545&units=0''>Forecast</a></span><br /><br />" +
           "<span class='link'><a href='http://weather.weatherbug.com/doppler-radar.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather/local-radar/doppler-radar.html?zcode=z5545&units=0''>Radar</a></span><br /><br />" +
             "<span class='link'><a href='http://community-weather.weatherbug.com/community/weather-photos/photo-gallery.html' target='_blank' onclick='Javascript:this.href='http://community-weather.weatherbug.com/community/weather-photos/photo-gallery.html?zcode=z5545&units=0&zip=47872''>Photos</a></span>" +
            "</div>" +
            "<div class='wXlinks2'>" +
            "<span class='link'><a href='http://weather.weatherbug.com/weather-cams.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather/weather-cams/local-cams.html?zcode=z5545&units=0''>Cameras</a></span><br /><br />" +
             "<span class='link'><a href='http://weather.weatherbug.com/weather-reports.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/weather-reports.html?zcode=z5545&units=0&zip=47872''>News</a></span><br /><br />" +
             "<span class='link'><a href='http://weather.weatherbug.com/travel-forecast.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/travel-forecast.html?zcode=z5545&units=0&zip=47872''>Travel</a></span>" +
            "</div>" +
           "<div class='footer'>" +
           "<a href='http://weather.weatherbug.com/default.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather.html?zcode=z5545&units=0''><img src='http://img.weather.weatherbug.com/images/stickers/v2/160x600/local.jpg' border='0' alt='WeatherBug' /></a><br />" +
           "<a href='http://weather.weatherbug.com/default.html' target='_blank' onclick='Javascript:this.href='http://weather.weatherbug.com/IN/Rockville-weather.html?zcode=z5545&units=0''><img src='http://img.weather.weatherbug.com/images/stickers/v2/160x600/bt-wxbug-logo.jpg' border='0' id='logo' alt='WeatherBug' /></a><br />" +
           "<div class='footertext'>Your weather just got better.</div>" +
           "</div>";
        JLabel label = new JLabel(htmlText);
        this.add(label);
    public static void main(String args[]) {
        JFrame frame = new JFrame();
        HtmlTest htmlTest = new HtmlTest();
        frame.add(htmlTest);
        frame.pack();
        frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
}

Java's HTML support is pretty minimal. You can't use stylesheets. I'm skeptical as to whether DIV tags work either

Similar Messages

  • Displaying HTML Content in Swing

    Say I was developing an email client, and I wanted to display HTML based email.
    How would I go about that.
    Are there any libraries out there that can parse through HTML and display it? And what about JavaScript?

    Use Search!
    http://developer.java.sun.com/developer/qow/archive/29/index.html

  • Display HTML in Java Applet

    Is it possible to display HTML text in some control in Applet. I do not want to use the swing class for that. please guide me. I am currently using the TextArea to display text which displays text only in a single color. But I want to display text in multicolor. How to do it. If possible please show me with an example.

    You will have to write your own component. Look at java.awt.FontMetrics to get the size of a string. Use
    g.setColor(Color.blue);
    Graphics.drawString(myString,x,y);
    to draw a blue string.

  • HTML with swing

    Hi,
    Is there a swing component to display html?
    How can I display an HTML file within a JFrame ?
    Thanks!

    Here's some sample code for printing a html file inside a JEditorPane.
    private void displayHTMLFile() {     
    /* HTMLEditorKit is used for displaying html files in JEditorPane */
    HTMLEditorKit htmlKit = new HTMLEditorKit();
    JEditorPane editPane = new JEditorPane();
    editPane.setEditorKit( htmlKit );
    editPane.setEditable( false );
    try {
    /* read the html file using an input stream reader */
    InputStreamReader in = new InputStreamReader(
    new FileInputStream( "try.html" ), "iso-8859-1" );
    /* give the input stream reader to the htmlkit to read */
    htmlKit.read( in, editPane.getDocument(), 0 );
    } catch ( Exception e ) {
    System.out.println(e.toString());
    /* display the editor pane inside a scroll pane */
    JScrollPane scroll     = new JScrollPane( editPane );
    getContentPane().add( scroll, "Center" );                    
    }     

  • Any Way to display HTML pages on Applet

    Hi All,
    Is there any way to show web pages on Applet?
    Is it possible ?

    I am not aware of a simple way to display HTML in an applet. However, I have used the JEditorPane to display HTML documents. Handling links, etc. with this component requires some effort. Also requires Swing.
    Have you considered using the applet to display a page on the browser. (i.e. getAppletContext().showDocument(URL, [frame name]))? Just an idea.
    Good luck.

  • How Do I Display HTML Formatted Text From A Data Table In Crystal Reports?

    I'm creating reports in Crystal XI.  The information being displayed in the reports comes from data tables where the text is formatted in HTML.
    I've worked with Crystal Reports enough to know that HTML text pulled from a data table doesn't appear in Crystal the same way it does in a web browser.  Crystal Reports ignores all the tags (...unless I'm missing something...) and just displays the text.
    Someone far more Crystal savy than I (...who I don't have access to...) came up with a Formula Field workaround that tricks Crystal Reports into displaying some basic HTML tags.  Here's that workaround:
    <!--
    stringVar TableName := ;
    TableName := Replace (TableName, "<ul>","<br> <br>");
    TableName := Replace (TableName, "<li>", "<br>   &bull; ");
    TableName := Replace (TableName, "</li>", "");
    TableName := Replace (TableName, "</ul>","<br> <br>");
    TableName := Replace (TableName, "<a", "<u><font color='blue'");
    TableName := Replace (TableName, "</a>", "</font></u>");
    TableName
    -->
    QUESTION - Does any similar workaround exist so I can display an HTML Table in Crystal Reports?  If not, is there any way to display HTML formatted text from a data table in Crystal Reports as it would appear in a web browser?

    Hi Steven,
    To display html text in Crystal Reports follows these steps.
    1. Right click on the field and select Paragraph tab.
    2. Under 'Text Interpretation' select 'HTML Text' and click OK.
    I have tried using the way,but it never works.So reply me if there is any way to solve the issue

  • How to display HTML response file in user's browser following submission of Livecycle form

    I have a PDF form created via Livecycle that does a HTTP submit to the webserver. The server returns a HTML 'submission receipt' page which is either opened in Acrobat or the user's web browser.
    Previously this process worked fine when submitting from adobe reader - the html receipt file would always automatically open OK in the user's browser. However, with newer versions of Reader (11.0.0+) I now get this error and no attempt to open the user's web browser:
    An error occurred during the submit process. Cannot process content of type text/html
    I realise why I get the error - Adobe reader can't display HTML files.
    What I don't understand is why it doesn't open the html file in the user's browser like it has been doing for years.
    Does anyone have any idea how I can fix this (without changing the response content type to PDF/FDF)?

    I had the same issue as you and we used FDF status, then eventually went with returning an XDP  that filled out a receipt section of the form.

  • How to display HTML file  (on server path) to ADF jspx page ?

    Hi Team,
    We have a requirement to display HTML content which is in tabular format on a page. This page is jspx page based on page template and this html has to be shown on a radio button select. I am trying to do this with Jquery but since the id of all components in jspx comes as pt1:id (pt1 being the id of page template) and : being a special character in Jquery, I am not able to proceed further.
    the syntax of Jquery to load html file a POC has been done outside Jdeveloper is working fine with a general syntax of
    $("#selector".load("html path"));
    Please let me know is they any other solution to load the file?
    Thanks
    Pavan

    For example
    - (void)viewDidLoad {
        [super viewDidLoad];
        NSURL *fileURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"readMe" ofType:@"html"]];
        [infoWebView loadRequest:[NSURLRequest requestWithURL:fileURL]];
    and from the .h
    @property (nonatomic, retain) IBOutlet UIWebView *infoWebView;

  • How to display HTML file from Unix server on UI at runtime

    Hi Experts,
    My requirement is to display  HTML files,  related to some particular person, on UI. The file is existing on a separate UNIX server and a file related to one person may have a lot of attached files as well , as is the case generally with HTML files, including pictures etc. So it is no use transferring file on my CRM system, as the files are kept separately on this UNIX server which is particularly for this kind of storage.
    I am able to show files residing on MIME repository ( I created some new HTML files )  of my CRM system on UI. but I don't know how to go ahead with this particular requirement.
    One idea is that I can map one folder of my application server to that unix server so that I can see the HTML files in this particular folder. but I don't know how to map MIME repository folder to application server directory or directly to the UNIX server .
    Please advise. Is my approach correct or is there any other way ?
    thanks in advance.
    Regards,
    Vikas

    Maybe this is too simple, but have you got an HTTP server on the UNIX machine? You could simply link the URL into you CRM application and display the contents directly from UNIX.
    cheers Carsten

  • How to display HTML formatted text in the field with Item Style: Raw Text

    How can I display HTML formatted text in the field with Item Style: Raw Text.
    Currently the Item Style is Raw Text, but the text is being displayed along with HTML tags without formatting.
    Regards

    Hi,
    Use Item Style formattedText.
    Regards,
    Gyan

  • Display HTML stored in a table

    Hello,
    I want to display HTML Code which is stored in a table.
    Now I have a display as text item and there the HTML is not rendered properly...
    So what must i do to show the HTML Code properly?
    What kind of item should I use?
    Thank you,
    Tim

    Thank you Carsten,
    I had the wrong Item.
    I used "display as text (saves state)"....
    Regards,
    Tim

  • Display HTML code in Crystal Reports

    We have a field in the database in which the data is encoded HTML, it includes links to images.  I have tried to use the RTF/HTML interpretation option for the field but it doesn't work.  I saw on the other thread that there's limitation to displaying HTML - I am using Cyrstal Reports XI.  So the crysal can't understand img tags correct?  I am allowing users to do just about anything with HTML so it's hard to find a workaround if the we have to limit the tags.  Would this issue be fixed in the future?  Any piece of advice how to handle this would be great!
    Thanks.

    Hi Pizzaz,
    The HTML tags that are supported by Crystal Reports are:
    " html
    " body
    " div (causes a paragraph break)
    " tr (causes only a paragraph break; does not
    preserve column structure of a table)
    " span
    " font
    " p (causes a paragraph break)
    " br (causes a paragraph break)
    " h1 (causes a paragraph break, makes the font bold
    & twice default size)
    " h2 (causes a paragraph break, makes the font bold
    & 1.5 times default size)
    " h3 (causes a paragraph break, makes the font bold
    & 9/8 default size)
    " h4 (causes a paragraph break, makes the font bold)
    " h5 (causes a paragraph break, makes the font bold
    & 5/6 default size)
    " h6 (causes a paragraph break, makes the font bold
    & 5/8 default size)
    " center
    " big (increases font size by 2 points)
    " small (decreases font size by 2 points if it's 8
    points or larger)
    " b
    " i
    " s
    " strike
    " u
    And the supported HTML attributes are:
    " align
    " face
    " size
    " color
    " style
    " font-family
    " font-size
    " font-style
    " font-weight
    Hope this helps you!
    Regards,
    Anindita

  • Display HTML Tags on web browser

    My problem is display Html code in web browser.
    i try TextArea.htmlText, Label.htmlText... but they don't
    work...
    i'm searching in google.com and i know Html Component can do
    that, but it not well because i don't have money for that.
    Some body help me for my problem.
    Thanks so much. !
    nice day every body.

    The htmlText property should work however only a few basic
    html tags are supported as far as I know.

  • Help -- How to display Html text in a JEditorPane

    I'm trying to display html in a JEditorPane (html is obtained by transforming Xml and Xsl). So after i do the transformation i have a string which is the html source to be displayed. But when i use editorpane.setText(htmlString) method it is displaying the html source in the editorpane. I also tried using the HTMLEditorKit's read method. Even then its displaying the html source. But when i store the html source as a html file and give the editorpane, the url of the html file, it displays properly.
         I would be so grateful if u can help in displaying the html (which i have as a string) instead of the source...
    Thank you so much...

    Hi, after struggling with problem, the solution seems to be to ditch the content type meta tag, JEditorPane seems to barf (silently!) on this...
    So, to turn this off...
    transformer.setOutputProperty(OutputKeys.ENCODING,"");
    Cheers
    Greg

  • Can I display html pages in flash player

    Hi all,
    Can I display html pages in flash player, i mean swf. Plz
    help me if it can be done. Can I call html pages in flash (i mean
    in flash player no new window)
    Thanks

    hi,
    Actullay i want the site to be opened with in the flash
    player, just like iframe in dreamweaver calling the external site
    in the mail html page. Plz Help me accessing external site page
    with in flash player
    Thanks

Maybe you are looking for

  • Error when loading data from DSO to Cube

    Hi, After upgrading to 2004s we get the following error message when trying to load data from a DSO to a Cube: Unexpected error: RSDRC_CONVERT_RANGES_TO_SELDR Has anyone experienced a similar problem or have some guidelines on how to resolve it? Kind

  • IS there a way to prevent nenroll from a class

    Hi Is there a way where we can prevent a learner from unenrolling from a class. For Eg If a manager enrolls a learner into a class then the learner should not be able to unenroll from the class. I dont know if this feature is there with OLM. I know o

  • TNS-12560: TNS:protocol adapter error and TNS-00530: Protocol adapter error

    i just installed oracle 11g on my windows xp professional box. Which user and password shall i use. What username and password should i be using to login to sql plus? when i use "Scott" "Tiger" it gives me ORA-12560: TNS:protocol adapter error occurr

  • Import Previews are very poor/pixelated ... D90 RAW

    When I am importing my NEF files from my D90 with a card reader, my import previews are of a very poor image quality. Once the images are imported, previews look great. Is there any way to improve the quality of import previews from the SD card?

  • Flash Player 10.1 crashing in Safari when playing H.264 .mov files

    Since installing Flash Player 10.1.53.64 on a Mac OS X 10.6.4 system, WebKitPluginHost in Safari Version 5.0 (6533.16) crashes every time when playing H.264 Quicktime movie. We have disabled hardware acceleration and tried other things to no avail. I