how should I change the color of visited link shown in a jeditorpane?
Printable View
how should I change the color of visited link shown in a jeditorpane?
no answer???????????
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):
If that doesn't work try using the vlink inside the body tag:Code :<style type="text/css"> a:visited{ color:#000000; //or whatever color you wish } </style>
Code :<body vlink="#000000">
Thanks , I am using the following code but it generates error
Code :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>);
You need to escape the quotes, or the compiler will generate an error. Try the following
Code :styleSheet.addRule("<style type=\"text/css\">a:visited{color:#000000;}</style>");
thanks but it doesn't change the color of visited links.