2

I have just recently added a update log to my game. I am using tumblr to show the update news. I used simple code (Listed Below) to show it but when I run it it looks nothing like the original tumblr!

package javaapplication32;

import javax.swing.*;

public class GetWebPage {
    public static void main(String args[]) throws Exception {
      JEditorPane website = new JEditorPane("http://smo-gram.tumblr.com/");
      website.setEditable(false);

      JFrame frame = new JFrame("Google");
      frame.add(new JScrollPane(website));
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setVisible(true);
      frame.pack();
    }

}
1
  • I'm not big into web stuff but I think your problem is that you are not retrieving any of the style sheets that make the webpage look nice. I could be completely wrong and I apologize in advance :P Commented Sep 24, 2013 at 21:42

3 Answers 3

3

Check out http://java.dzone.com/articles/web-browser-your-java-swing.

JxBrowser lets you display any webpage,by embedding a browser into your swing application.

Sign up to request clarification or add additional context in comments.

1 Comment

However, it should be noted that JxBrowser is not open source. You should purchase valid license in order to use it in your application.
1

There's a few other options available. If you need HTML5 support, switch over to JavaFX (It's way better than Swing IMO). There's also a HTML4/CSS2 renderer available for Swing called Cobra, and it seems pretty good. Another option would be Frostwire JWebBrowser, if you don't mind including native code, it seems to give you full HTML5 and CSS3 in Swing.

Comments

1

Remove the call of pack() method. In another way, do not expect much of HTML Swing. Supports up to HTML 3.2 (http://www.w3.org/TR/REC-html32.html).

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

public class GetWebPage {
    public static void main(String args[]) throws Exception {
        JEditorPane website = new JEditorPane("http://smo-gram.tumblr.com/");
        website.setEditable(false);
        JFrame frame = new JFrame("Google");
        frame.add(new JScrollPane(website));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(800, 600);
        frame.setVisible(true);
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.