I am currently working on an application in Java which has an JTextPane
editor which will contain a set of custom expressions.
I am attempting to add Syntax Highlighting to the editor which would make it easier in identifying the different expressions in the editor.
I have generated the tokens which provides the positions to be highlighted but the problem is when there is like 100+ lines of expressions in the editor, it takes a while to highlight the document when changes have been made.
I am using the following function to highlight the different parts of the expressions:
// StyledDocument styledDocument = editorPane.getStyledDocument();
styledDocument.setCharacterAttributes(tokenInfo.getStart(), tokenInfo.getText().length(), style, false);
How may I improve the performance of the syntax highlighting?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…