aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to color a particular word in jtextpane ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic
Author

how to color a particular word in jtextpane ?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 682

i m making a text editor in that when ever user type a certain java keyword like void just that word will be appeared as blue and rest other work should be red
i m using keylistener but unfortunately my logic is notworking here
what is happening here is when i write some thing like
class void then i press enter then the color of the text changes to red and from then on the entire text is written in red color
same is the case with blue ....so please can you tell me where i m wrong and what is key thing in this which i m missing ?
if you can provide some example than that would be great help because in the google every code is not understandable


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

This is still the same problem as this one. UseOneThreadPerQuestion.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to color a particular word in jtextpane ?
 
Similar Threads
How can we make highlight some text in text editor in java????
how to paint a particular word in a string ?
Exception
Changing Color of a selectedtext in TextArea
Will a started thread run to completion in this example?