I have started a project that requires syntax highlighting and code pletion (a window pops up at the caret location providing suggestions) and can't find a suitable solution. There are multiple Swing ponents which take text input e.g. JTextArea, JTextPane and JEditorPane which makes it significantly more difficult to figure out which is the correct one to use.
The project is a programmer specific text editor which will have integration with the unity game engine. This meaning code pletion and highlighting will be done on JavaScript and C# syntax.
It might be obvious but the general idea is that when the user types, certain words change to a specified colour, these words would be stored in a text file. For the code pletion I need to be able to grab the currently typed letters, this detection process will restart by using the space character as the delimiter.
Thanks for your time :)
I have started a project that requires syntax highlighting and code pletion (a window pops up at the caret location providing suggestions) and can't find a suitable solution. There are multiple Swing ponents which take text input e.g. JTextArea, JTextPane and JEditorPane which makes it significantly more difficult to figure out which is the correct one to use.
The project is a programmer specific text editor which will have integration with the unity game engine. This meaning code pletion and highlighting will be done on JavaScript and C# syntax.
It might be obvious but the general idea is that when the user types, certain words change to a specified colour, these words would be stored in a text file. For the code pletion I need to be able to grab the currently typed letters, this detection process will restart by using the space character as the delimiter.
Thanks for your time :)
Share Improve this question asked Jan 9, 2013 at 6:38 someSortOfProgrammersomeSortOfProgrammer 1632 silver badges5 bronze badges 1-
6
"Thanks for your time :)" Do you have a question? If so, what is it? BTW -
JTextArea
is for plain text so will be unsuited to this task, whereasJTextPane
andJEditorPane
support styled text. – Andrew Thompson Commented Jan 9, 2013 at 6:40
2 Answers
Reset to default 6See my answer here which shows auto pletion for JTextComponent
, it can show pop up window of auto pletion words to the current caret index on JTextPane
/JEditorPane
(+1 @AndrewThompson for the idea):
For JTextField
:
and for other JTextComponent
s i.e JTextPane
, JEditorPane
etc its shown at the current caret index:
To change text colour of words (i.e syntax highlight) have a look here:
Or if you want rather a highlighted word. See here:
you can look at ponents from jintilla (a JNI wrapper around the widely used scintilla) or jedit if their licensing terms fit your use case.