Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JTextArea/text component question

Reply
Thread Tools

JTextArea/text component question

 
 
:-o
Guest
Posts: n/a
 
      05-04-2005
Thanks,

I'm using a JTextArea to store data read from a file and I need to implement a
search->find
feature that highlights the text found in the JTextArea.

I've looked at Document and EditorKit.......found a highlighter that JTextArea
inherits from javax.swing.text.

Where should I look to find the methods required to do the setStartOffsetAt and
setStopOffsetAt within
text in the JTextArea?

Or should I look at one of the other text components....




 
Reply With Quote
 
 
 
 
Alan Moore
Guest
Posts: n/a
 
      05-04-2005
On Wed, 4 May 2005 15:24:24 -0400, "" <(E-Mail Removed)> wrote:

>Thanks,
>
>I'm using a JTextArea to store data read from a file and I need to implement a
>search->find
>feature that highlights the text found in the JTextArea.
>
>I've looked at Document and EditorKit.......found a highlighter that JTextArea
>inherits from javax.swing.text.
>
>Where should I look to find the methods required to do the setStartOffsetAt and
>setStopOffsetAt within
>text in the JTextArea?
>
>Or should I look at one of the other text components....


Will you be highlighting one result at a time, or all of them at once?
If it's one at a time, you can use the existing Highlighter with
textArea.getHighlighter(); otherwise you'll have to create a new one.
In either case, you'll need to create a new HighlightPainter in a
different color. DefaultHighter and its inner class
DefaultHighlightPainter are what you'll be using. If you installed
the JDK source code, you can look at the DefaultCaret class for an
example of highlighting one hit at a time; that's where selection
highlighting is done.
 
Reply With Quote
 
 
 
 
:-o
Guest
Posts: n/a
 
      05-04-2005

"Alan Moore" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Wed, 4 May 2005 15:24:24 -0400, "" <(E-Mail Removed)> wrote:
>
> >Thanks,
> >
> >I'm using a JTextArea to store data read from a file and I need to implement

a
> >search->find
> >feature that highlights the text found in the JTextArea.
> >
> >I've looked at Document and EditorKit.......found a highlighter that

JTextArea
> >inherits from javax.swing.text.
> >
> >Where should I look to find the methods required to do the setStartOffsetAt

and
> >setStopOffsetAt within
> >text in the JTextArea?
> >
> >Or should I look at one of the other text components....

>
> Will you be highlighting one result at a time, or all of them at once?


Yes, highlighting one at a time.

> If it's one at a time, you can use the existing Highlighter with
> textArea.getHighlighter(); otherwise you'll have to create a new one.
> In either case, you'll need to create a new HighlightPainter in a
> different color. DefaultHighter and its inner class
> DefaultHighlightPainter are what you'll be using. If you installed
> the JDK source code, you can look at the DefaultCaret class for an
> example of highlighting one hit at a time; that's where selection
> highlighting is done.


Thanks....


 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fast Question: Index of a Component in another component pek Java 3 07-24-2007 01:56 AM
Remoting Component --> Com+ Component: Karuppasamy ASP .Net 0 01-15-2004 10:21 AM
com+ component and Component Service Karuppasamy ASP .Net 1 01-14-2004 11:30 PM
com+ component and Component Service Karuppasamy ASP .Net 0 01-13-2004 06:09 PM
Re: Calling a .NET component from a COM component remotely Soni ASP .Net 0 07-25-2003 04:33 AM



Advertisments