Hi Ajay,
        Label doesn't have near the capability of a TextArea (or
TextPane) as far as manipulation of its parts.  It is meant to be a
single piece of text, all with the same attributes.  And, in fact, if
you want to change the color of a single word, then you're going to have
to use TextPane, and set up some text spans that have different
attributes.  Or you could use a series of Labels, each with one piece of
the text, and line them up with a BoxPane or FlowPane so it appears they
are one.  That way you could change the attributes of one Label at a
time.  Caveat:  I haven't actually tried this, but I'm pretty sure you
could play with the margins and such on the enclosing container to make
this work pretty well.  But TextPane is the component that is actually
meant for this sort of thing, but it is a little bit more difficult to
setup the document structure.  But, you can take a look at the
TextPaneDemo.java file for examples on working with a TextPane, and
applying styles to various pieces of text within it.  You could make it
read-only (with "setEditable(false)") so that it simulates a Label in
appearance.

HTH,
~Roger Whitcomb

-----Original Message-----
From: Ajay Bhat [mailto:a.ajay.b...@gmail.com] 
Sent: Thursday, July 18, 2013 12:59 AM
To: dev@pivot.apache.org
Subject: Re: How to highlight text using Pivot?

On Jul 18, 2013 12:13 AM, "Ajay Bhat" <a.ajay.b...@gmail.com> wrote:
>
> Hi,
>
> I'm using Pivot API for GUI application. I'd like to know how I can
display some text in a text area being highlighted, by basically being
selected when I use a ActionListener.
>

As a follow up to this question I'd also like to know how to highlight
text in a label

> Eg: Entered text is:
>
> The quick brown fox jumps over the lazy dog.
>
> And I want to highlight the word 'quick' in the text area by having it
selected on clicking some button. How do I do it?
>

Let's say I have the above sentence in a label and I need to highlight
'brown' by say changing color of the word to brown. I have the offset of
the beginning of the word. How to do it?

> Thanks,
> Ajay

Reply via email to