views:

339

answers:

4

hi, i am writing an application that the user need to writes a javascript script as an input, right now i have a simple JTextArea but i would like to change it with something that will do some highlights and code coloring to make the script more coherent.

do you know any open source thing that does that?

thanks

A: 

Take a look at what the NetBeans Platform provides. I know that they do release components as JARfiles, but they're not available in the Maven central repo, which has kept me from using any.

kdgregory
+2  A: 

Try jEdit. It is mainly an editor written in Java and not an editor component. But perhaps you can extract the editor component from the jar file.

Just an idea.

nalply
http://syntax.jedit.org/
Mark
+1  A: 

Standard JEditorPane swing component will do it.

UPDATE: Check out the API and tutorial

eugener
Out of the box, or do you have to create an `EditorKit`/`Document` that parses the text and provides the highlighting?
kdgregory
@kdgregory By default JEditorPane knows about html, rtf and plain text. But more kits/documents can be configured
eugener
A: 

RSyntaxTextArea

RSyntaxTextArea is a syntax highlighting text component for Java Swing. It extends JTextComponent so it integrates completely with the standard javax.swing.text package. It is fast and efficient, and can be used in any application that needs to edit or view source code.

RSyntaxTextArea was originally part of the RText programmer's text editor, but is currently being made into a separate component, reusable in any Swing application.

Screenshot:http://fifesoft.com/rsyntaxtextarea/images/rsta1.png

逸飞