I'm currently programming an IDE, and am using a JTextPane as the "code-editor".
Now, I am trying to add syntax highlighting to the JTextPane, but am having some trouble...
I'm using HTML to replace http://img21.imageshack.us/img21/6185/910b3b10cad4487f9c96d43.png with :
private void jTextPane1KeyTyped(java.awt.event.KeyEvent evt) {
String SyntaxedCode = jTextPane1.getText();
jTextPane1.setText(SyntaxedCode.replaceAll("//", "<span style='color: green'>//</span>"));
}
Getting The Result:
Now, the part I'm struggling with, is the fact that the JTextPane is limiting my spacing... I can only add one or two spaces in a row, and then the JTextPane just stops accepting spaces. Also, I can't use the enter key to go to a new line.
Why is it restricting me like this, and how can I avoid it?
Thanks in advance;