Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
450 views
in Technique[技术] by (71.8m points)

Java Swing: Syntax Highlighting in JTextPane

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...