JSyntaxHighlighter/JSyntaxHighlighterObject.java
public void highlightSyntax(){
		
		clearSyntaxColors();
		
		// Default
		Pattern pattern = Pattern.compile(syntaxRules.getDefaultRule());
		Matcher match = pattern.matcher(this.getText());
		while (match.find()){
			updateSyntaxColor(match.start(), match.end() - match.start(), syntaxStyle.DEFAULT, Font.BOLD);
		}
		
		// Functions
		Pattern patternFun = Pattern.compile(syntaxRules.getFunctionRule());
		Matcher matchFun = patternFun.matcher(this.getText());
		while (matchFun.find()){
			updateSyntaxColor(matchFun.start(), matchFun.end() - matchFun.start(), syntaxStyle.FUNCTION, 3);
		}
		
		// Class
		Pattern patternClass = Pattern.compile(syntaxRules.getClassRule());
		Matcher matchClass = patternClass.matcher(this.getText());
		while (matchClass.find()){
			updateSyntaxColor(matchClass.start(), matchClass.end() - matchClass.start(), syntaxStyle.CLASS, 3);
		}
		
		// Keywords
		Pattern patternKey = Pattern.compile(syntaxRules.getKeywordsRule());
		Matcher matchKey = patternKey.matcher(this.getText());
		while (matchKey.find()){
			updateSyntaxColor(matchKey.start(), matchKey.end() - matchKey.start(), syntaxStyle.KEYWORDS, Font.BOLD);
		}

		// Operators
		Pattern patternOp = Pattern.compile(syntaxRules.getOperatorRule());
		Matcher matchOp = patternOp.matcher(this.getText());
		while (matchOp.find()){
			updateSyntaxColor(matchOp.start(), matchOp.end() - matchOp.start(), syntaxStyle.KEYWORDS, Font.BOLD);
		}
			
		// Numbers
		Pattern patternNum = Pattern.compile(syntaxRules.getNumericalRule());
		Matcher matchNum = patternNum.matcher(this.getText());
		while (matchNum.find()){
			updateSyntaxColor(matchNum.start(), matchNum.end() - matchNum.start(), syntaxStyle.NUMERICAL, Font.BOLD);
		}
		
		// Generic String
		Pattern patternStr = Pattern.compile(syntaxRules.getStringRule());
		Matcher matchStr = patternStr.matcher(this.getText());
		while (matchStr.find()){
			updateSyntaxColor(matchStr.start(), matchStr.end() - matchStr.start(), syntaxStyle.STRINGS,Font.BOLD);
		}
		
		
		// String with escape character
		Pattern patternStrE = Pattern.compile(syntaxRules.getStringWithEscapeRule());
		Matcher matchStrE = patternStrE.matcher(this.getText());
		while (matchStrE.find()){
			updateSyntaxColor(matchStrE.start(), matchStrE.end() - matchStrE.start(), syntaxStyle.STRINGS, Font.BOLD);
		}
		
		// Comments (Single)
		Pattern patternC = Pattern.compile(syntaxRules.getSingleCommentRule());
		Matcher matchC = patternC.matcher(this.getText());
		while (matchC.find()){
			updateSyntaxColor(matchC.start(), matchC.end() - matchC.start(), syntaxStyle.COMMENTS, Font.ITALIC);
		}
				
		
		// Comments (Multilined)
		Pattern patternCML = Pattern.compile(syntaxRules.getMultiCommentRule());
		Matcher matchCML = patternCML.matcher(this.getText());
		while (matchCML.find()){
			updateSyntaxColor(matchCML.start(), matchCML.end() - matchCML.start(), syntaxStyle.COMMENTS, Font.ITALIC);
		}

	}
/**
	 * Start highlighting the syntax in the JTextPane
	 */
Start highlighting the syntax in the JTextPane
Start highlighting the syntax in the JTextPane
public void highlightSyntax(){
		clearSyntaxColors();
		Pattern pattern = Pattern.compile(syntaxRules.getDefaultRule());
		Matcher match = pattern.matcher(this.getText());
		while (match.find()){
			updateSyntaxColor(match.start(), match.end() - match.start(), syntaxStyle.DEFAULT, Font.BOLD);
		}
		Pattern patternFun = Pattern.compile(syntaxRules.getFunctionRule());
		Matcher matchFun = patternFun.matcher(this.getText());
		while (matchFun.find()){
			updateSyntaxColor(matchFun.start(), matchFun.end() - matchFun.start(), syntaxStyle.FUNCTION, 3);
		}
		Pattern patternClass = Pattern.compile(syntaxRules.getClassRule());
		Matcher matchClass = patternClass.matcher(this.getText());
		while (matchClass.find()){
			updateSyntaxColor(matchClass.start(), matchClass.end() - matchClass.start(), syntaxStyle.CLASS, 3);
		}
		Pattern patternKey = Pattern.compile(syntaxRules.getKeywordsRule());
		Matcher matchKey = patternKey.matcher(this.getText());
		while (matchKey.find()){
			updateSyntaxColor(matchKey.start(), matchKey.end() - matchKey.start(), syntaxStyle.KEYWORDS, Font.BOLD);
		}
		Pattern patternOp = Pattern.compile(syntaxRules.getOperatorRule());
		Matcher matchOp = patternOp.matcher(this.getText());
		while (matchOp.find()){
			updateSyntaxColor(matchOp.start(), matchOp.end() - matchOp.start(), syntaxStyle.KEYWORDS, Font.BOLD);
		}
		Pattern patternNum = Pattern.compile(syntaxRules.getNumericalRule());
		Matcher matchNum = patternNum.matcher(this.getText());
		while (matchNum.find()){
			updateSyntaxColor(matchNum.start(), matchNum.end() - matchNum.start(), syntaxStyle.NUMERICAL, Font.BOLD);
		}
		Pattern patternStr = Pattern.compile(syntaxRules.getStringRule());
		Matcher matchStr = patternStr.matcher(this.getText());
		while (matchStr.find()){
			updateSyntaxColor(matchStr.start(), matchStr.end() - matchStr.start(), syntaxStyle.STRINGS,Font.BOLD);
		}
		Pattern patternStrE = Pattern.compile(syntaxRules.getStringWithEscapeRule());
		Matcher matchStrE = patternStrE.matcher(this.getText());
		while (matchStrE.find()){
			updateSyntaxColor(matchStrE.start(), matchStrE.end() - matchStrE.start(), syntaxStyle.STRINGS, Font.BOLD);
		}
		Pattern patternC = Pattern.compile(syntaxRules.getSingleCommentRule());
		Matcher matchC = patternC.matcher(this.getText());
		while (matchC.find()){
			updateSyntaxColor(matchC.start(), matchC.end() - matchC.start(), syntaxStyle.COMMENTS, Font.ITALIC);
		}
		Pattern patternCML = Pattern.compile(syntaxRules.getMultiCommentRule());
		Matcher matchCML = patternCML.matcher(this.getText());
		while (matchCML.find()){
			updateSyntaxColor(matchCML.start(), matchCML.end() - matchCML.start(), syntaxStyle.COMMENTS, Font.ITALIC);
		}
	}
public void highlightSyntax ( ) { clearSyntaxColors ( ) ; Pattern pattern = Pattern . compile ( syntaxRules . getDefaultRule ( ) ) ; Matcher match = pattern . matcher ( this . getText ( ) ) ; while ( match . find ( ) ) { updateSyntaxColor ( match . start ( ) , match . end ( ) - match . start ( ) , syntaxStyle . DEFAULT , Font . BOLD ) ; } Pattern patternFun = Pattern . compile ( syntaxRules . getFunctionRule ( ) ) ; Matcher matchFun = patternFun . matcher ( this . getText ( ) ) ; while ( matchFun . find ( ) ) { updateSyntaxColor ( matchFun . start ( ) , matchFun . end ( ) - matchFun . start ( ) , syntaxStyle . FUNCTION , 3 ) ; } Pattern patternClass = Pattern . compile ( syntaxRules . getClassRule ( ) ) ; Matcher matchClass = patternClass . matcher ( this . getText ( ) ) ; while ( matchClass . find ( ) ) { updateSyntaxColor ( matchClass . start ( ) , matchClass . end ( ) - matchClass . start ( ) , syntaxStyle . CLASS , 3 ) ; } Pattern patternKey = Pattern . compile ( syntaxRules . getKeywordsRule ( ) ) ; Matcher matchKey = patternKey . matcher ( this . getText ( ) ) ; while ( matchKey . find ( ) ) { updateSyntaxColor ( matchKey . start ( ) , matchKey . end ( ) - matchKey . start ( ) , syntaxStyle . KEYWORDS , Font . BOLD ) ; } Pattern patternOp = Pattern . compile ( syntaxRules . getOperatorRule ( ) ) ; Matcher matchOp = patternOp . matcher ( this . getText ( ) ) ; while ( matchOp . find ( ) ) { updateSyntaxColor ( matchOp . start ( ) , matchOp . end ( ) - matchOp . start ( ) , syntaxStyle . KEYWORDS , Font . BOLD ) ; } Pattern patternNum = Pattern . compile ( syntaxRules . getNumericalRule ( ) ) ; Matcher matchNum = patternNum . matcher ( this . getText ( ) ) ; while ( matchNum . find ( ) ) { updateSyntaxColor ( matchNum . start ( ) , matchNum . end ( ) - matchNum . start ( ) , syntaxStyle . NUMERICAL , Font . BOLD ) ; } Pattern patternStr = Pattern . compile ( syntaxRules . getStringRule ( ) ) ; Matcher matchStr = patternStr . matcher ( this . getText ( ) ) ; while ( matchStr . find ( ) ) { updateSyntaxColor ( matchStr . start ( ) , matchStr . end ( ) - matchStr . start ( ) , syntaxStyle . STRINGS , Font . BOLD ) ; } Pattern patternStrE = Pattern . compile ( syntaxRules . getStringWithEscapeRule ( ) ) ; Matcher matchStrE = patternStrE . matcher ( this . getText ( ) ) ; while ( matchStrE . find ( ) ) { updateSyntaxColor ( matchStrE . start ( ) , matchStrE . end ( ) - matchStrE . start ( ) , syntaxStyle . STRINGS , Font . BOLD ) ; } Pattern patternC = Pattern . compile ( syntaxRules . getSingleCommentRule ( ) ) ; Matcher matchC = patternC . matcher ( this . getText ( ) ) ; while ( matchC . find ( ) ) { updateSyntaxColor ( matchC . start ( ) , matchC . end ( ) - matchC . start ( ) , syntaxStyle . COMMENTS , Font . ITALIC ) ; } Pattern patternCML = Pattern . compile ( syntaxRules . getMultiCommentRule ( ) ) ; Matcher matchCML = patternCML . matcher ( this . getText ( ) ) ; while ( matchCML . find ( ) ) { updateSyntaxColor ( matchCML . start ( ) , matchCML . end ( ) - matchCML . start ( ) , syntaxStyle . COMMENTS , Font . ITALIC ) ; } }
Start highlighting the syntax in the JTextPane
Start highlighting the syntax in the JTextPane
// Default // Functions // Class // Keywords // Operators // Numbers // Generic String // String with escape character // Comments (Single) // Comments (Multilined)