Results 1 to 2 of 2
  1. #1
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default set jEditorPane css problem

    hello,
    I'm trying to change the font color of text in a jEditorPane in a desktop application. bellow is the code i'm using:

    Java Code:
    try{
        System.out.print("test");    
        jEditorPane1.setContentType("text/html");
        HTMLEditorKit kit = new HTMLEditorKit();
        jEditorPane1.setEditorKit(kit);
        StyleSheet styleSheet = kit.getStyleSheet();
        styleSheet.addRule("<style type=\"text/css\"> p { color:red;}</style>");
    }
    catch (Exception e){
        jEditorPane1.setText(e.toString());
    }
    the following is the error that I get:

    Exception in thread "Thread-4" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2882)
    at java.lang.AbstractStringBuilder.expandCapacity(Abs tractStringBuilder.java:100)
    at java.lang.AbstractStringBuilder.append(AbstractStr ingBuilder.java:515)
    at java.lang.StringBuffer.append(StringBuffer.java:30 6)
    at java.io.StringWriter.write(StringWriter.java:77)
    at javax.swing.text.AbstractWriter.output(AbstractWri ter.java:679)
    at javax.swing.text.html.HTMLWriter.output(HTMLWriter .java:1172)
    at javax.swing.text.AbstractWriter.write(AbstractWrit er.java:547)
    at javax.swing.text.AbstractWriter.write(AbstractWrit er.java:497)
    at javax.swing.text.html.HTMLWriter.writeComment(HTML Writer.java:626)
    at javax.swing.text.html.HTMLWriter.writeAdditionalCo mments(HTMLWriter.java:646)
    at javax.swing.text.html.HTMLWriter.write(HTMLWriter. java:217)
    at javax.swing.text.html.HTMLEditorKit.write(HTMLEdit orKit.java:292)
    at javax.swing.text.JTextComponent.write(JTextCompone nt.java:1616)
    at javax.swing.JEditorPane.getText(JEditorPane.java:1 522)
    at webagent.WebAgentView.AppendJText(WebAgentView.jav a:518)
    at webagent.ReadURL.run(ReadURL.java:57)
    at java.lang.Thread.run(Thread.java:662)

    can anyone tell me what I'm doing wrong?

    Thanks
    jason

  2. #2
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default Anyone?

    Anyone have any suggestions or am i just going about this the wrong way? I want to have a some form of textfield where i can change the font color (for instance, make every other line red). if not with the jEditorPane, some other object i could use, and a working example would be great.

    thanks
    jason

Similar Threads

  1. Get Row/Column In JEditorPane
    By 67726e in forum AWT / Swing
    Replies: 3
    Last Post: 11-08-2010, 02:10 AM
  2. JEditorPane + MouseWheel
    By Moncleared in forum New To Java
    Replies: 2
    Last Post: 10-09-2010, 02:27 AM
  3. Problem with writting in JEditorPane.
    By marox in forum AWT / Swing
    Replies: 11
    Last Post: 04-21-2010, 12:25 AM
  4. JEditorPane Example
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 08:47 PM
  5. JEditorPane
    By drmmr11 in forum Java Applets
    Replies: 0
    Last Post: 08-02-2007, 07:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •