i have a project that has a JEditorPane
in netbeans, at the moment i have this being populated with a chosen .java file. what i would like to happen do is when the java file is loaded the syntax is colored appropriately so that it is easy to read other then the current plain text it is now.
Does anybody have any ideas on how to do this as i am unable to find any good examples of this online?
EDIT: ANSWER
I got this to finally work, i added the JSyntaxPane jar
file to my classpath (jsyntaxpane-0.9.5-b29.jar
to be exact) then i added the following two lines of code to get it working for my JEditorPane.
jsyntaxpane.DefaultSyntaxKit.initKit();
JEditorPane.setContentType("text/java");
This can also be used on the following languages: JavaScript, Properties, Groovy, C, C++, XML, SQL, Ruby and Python
... just by simply changing text/java
to text/LANGUAGE_YOU_WANT
in the above code