Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: changing the visited links color in JEditorpane

  1. #1
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default changing the visited links color in JEditorpane

    how should I change the color of visited link shown in a jeditorpane?


  2. #2
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Re: changing the visited links color in JEditorpane

    no answer???????????

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    183
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: changing the visited links color in JEditorpane

    Patience....If you are setting the content type to 'text/html', then this is dependent upon the html you provide. You can try to do so by setting a css style (not sure if this will work with a JEditorPane though):
    <style type="text/css">
    a:visited{
    color:#000000; //or whatever color you wish
    }
    </style>
    If that doesn't work try using the vlink inside the body tag:
    <body vlink="#000000">

  4. #4
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Re: changing the visited links color in JEditorpane

    Thanks , I am using the following code but it generates error
    JEditorPane text= new JEditorPane();
    			text.setContentType("text/html");
    			HTMLEditorKit kit = new HTMLEditorKit();
    			text.setEditorKit(kit);
    			StyleSheet styleSheet = kit.getStyleSheet();
    			styleSheet.addRule("<style type="text/css">
    a:visited{
    color:#000000; //or whatever color you wish
    }
    </style>);

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    183
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: changing the visited links color in JEditorpane

    You need to escape the quotes, or the compiler will generate an error. Try the following

    styleSheet.addRule("<style type=\"text/css\">a:visited{color:#000000;}</style>");

  6. #6
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Re: changing the visited links color in JEditorpane

    thanks but it doesn't change the color of visited links.

Similar Threads

  1. refreshing JEditorPane
    By nasi in forum AWT / Java Swing
    Replies: 9
    Last Post: April 9th, 2010, 05:01 AM
  2. writing to JEditorPane
    By nasi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 8th, 2010, 10:23 PM
  3. writting to jeditorpane
    By nasi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 5th, 2010, 06:49 AM
  4. create buttons in a JEditorPane
    By seeker in forum AWT / Java Swing
    Replies: 4
    Last Post: December 5th, 2009, 09:01 AM
  5. How prograssbarColor with differentThe color indicates
    By NARs in forum AWT / Java Swing
    Replies: 0
    Last Post: October 18th, 2009, 11:04 PM

Tags for this Thread