Loading and displaying HTML+CSS in Java

nutrimaneua

New Member
I am Trying to display a Xbox Gamer Card in my Java Program:Here is a GamerCard: http://gamercard.xbox.com/de-DE/anybody.cardCurrently I have the following:\[code\]import java.awt.Dimension;import java.io.BufferedReader;import java.io.InputStream;import java.io.InputStreamReader;import java.net.URL;import javax.swing.JEditorPane;import javax.swing.text.html.HTMLEditorKit;public class CardLoader extends JEditorPane { private static final long serialVersionUID = 1L; private static final String[] card = { "http://gamercard.xbox.com/de-DE/", ".card" }; private static final String styleSheetLink = "http://gamercard.xbox.com/Content/Gamercard/default/gamercard.css"; public CardLoader(String username) { HTMLEditorKit kit = new HTMLEditorKit(); this.setEditable(false); this.setPreferredSize(new Dimension(200, 135)); kit.getStyleSheet().addRule(URLCaS(styleSheetLink)); this.setEditorKit(kit); try { this.setPage(card[0] +username +card[1]); } catch (Exception e) { e.printStackTrace(); } } String URLCaS(String url){ InputStream in = null; String returner = new String(); try { in = new URL(url).openStream(); InputStreamReader inR = new InputStreamReader( in ); BufferedReader buf = new BufferedReader( inR ); String line; while ( ( line = buf.readLine() ) != null ) { returner += line + "\n"; } in.close(); } catch (Exception e){ e.printStackTrace(); } return returner.substring(3); }}\[/code\]It looks like, it can apply the StyleSheet, but not correctly.Hope someone can help me.
 
Back
Top