Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-31-2011, 11:54 PM   PM User | #1
roher4
New Coder

 
Join Date: Jul 2010
Location: Canada
Posts: 26
Thanks: 2
Thanked 0 Times in 0 Posts
roher4 is an unknown quantity at this point
Syntax Highlighting Problem

Hi,

I cannot find my error in my find & replace feature and was wondering if someone could help me find my error. I'm trying to compare a TextPane's (Named:textArea) text against an array.

Code:
		//Syntax Colouring Begins Here
		static String[] javaReserved = {"abstract", "assert", "class", "const", "continue", "default", "enum", "extends", "final", "finally", "goto", "implements", "import", "instanceof", "interface", "native", "new", "package", "private", "protected",
			"public", "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "try", "void", "volatile"};

		 void colourJavaReservedWords(){
			if (syntaxColouringEnabled==true) {		
				StyleConstants.setForeground(style,Color.orange);
				for(int i=0; i<javaReserved.length; i++){
					//if (javaReserved[i].indexOf(i).equals(textArea.getText().indexOf(i))) {
						if (javaReserved[i].equals(textArea.getText().indexOf(i))) {
							doc.setCharacterAttributes(javaReserved[i],javaReserved.length, textArea.getStyle("orange"),true);
						}
					}
				}
			}

Last edited by roher4; 06-01-2011 at 04:28 PM..
roher4 is offline   Reply With Quote
Reply

Bookmarks

Tags
coloring, java, reserved, syntax

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:30 PM.


Advertisement
Log in to turn off these ads.