Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to change the colors of the Text along with different inputs?
How to change the colors of the Text along with different inputs? [message #461860] Mon, 03 October 2005 17:19 Go to next message
Eclipse UserFriend
Originally posted by: qingxing20052.gmail.com

Dear all:

I met one probelm and hope to get some helps from you.

* My scenario:
There are two buttons, A and B. When A is pressed, the word "A" which is
blue will appear in textArea. Whereas when B is pressed, the word "B" which
is red will appear in textArea. I used the following method:
A mouse down event:{
textArea.setForeground(Specific Color);}

The result: All the comment in textArea are changed along with different
pressings of A and B. E.g. When button A is firstly pressed, word "A" is
blue. After that button B is pressed, the previous word "A" and latter word
"B" are changed (red) both. It is not my expected. My expected result is:
"A" still remain in blue, only "B" is in red. I know the method
sefForeground is not fit for my requirement. But is there any other mehtod
that I can use?

Any suggestion is welcome.

I am looking forward to hearing from you.

thx for your kindness and helps.

B.W.

N.B
Re: How to change the colors of the Text along with different inputs? [message #461861 is a reply to message #461860] Mon, 03 October 2005 17:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"eclipse.newcomer" <qingxing20052@gmail.com> wrote in message
news:dhrp6d$4rb$1@news.eclipse.org...
> Dear all:
>
> I met one probelm and hope to get some helps from you.
>
> * My scenario:
> There are two buttons, A and B. When A is pressed, the word "A" which is
> blue will appear in textArea. Whereas when B is pressed, the word "B"
> which
> is red will appear in textArea. I used the following method:
> A mouse down event:{
> textArea.setForeground(Specific Color);}
>
> The result: All the comment in textArea are changed along with different
> pressings of A and B. E.g. When button A is firstly pressed, word "A" is
> blue. After that button B is pressed, the previous word "A" and latter
> word
> "B" are changed (red) both. It is not my expected. My expected result is:
> "A" still remain in blue, only "B" is in red. I know the method
> sefForeground is not fit for my requirement. But is there any other mehtod
> that I can use?
>
Use StyledText.
---
Sunil
Re: How to change the colors of the Text along with different inputs? [message #461900 is a reply to message #461861] Tue, 04 October 2005 12:51 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
One other comment is that you should be listening for an SWT.Selection event
instead of SWT.MouseDown, so that keyboard presses of the button will be
detected as well.

For an example of using StyledText see
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet163.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup .

Grant

"Sunil Kamath" <sunil_kamath@nohotspammail.com> wrote in message
news:dhrph2$5ar$1@news.eclipse.org...
>
> "eclipse.newcomer" <qingxing20052@gmail.com> wrote in message
> news:dhrp6d$4rb$1@news.eclipse.org...
> > Dear all:
> >
> > I met one probelm and hope to get some helps from you.
> >
> > * My scenario:
> > There are two buttons, A and B. When A is pressed, the word "A" which is
> > blue will appear in textArea. Whereas when B is pressed, the word "B"
> > which
> > is red will appear in textArea. I used the following method:
> > A mouse down event:{
> > textArea.setForeground(Specific Color);}
> >
> > The result: All the comment in textArea are changed along with different
> > pressings of A and B. E.g. When button A is firstly pressed, word "A" is
> > blue. After that button B is pressed, the previous word "A" and latter
> > word
> > "B" are changed (red) both. It is not my expected. My expected result
is:
> > "A" still remain in blue, only "B" is in red. I know the method
> > sefForeground is not fit for my requirement. But is there any other
mehtod
> > that I can use?
> >
> Use StyledText.
> ---
> Sunil
>
>
Previous Topic:Table column headers of different color
Next Topic:Can the broswer component read a html file bundled in a jar(or a zip) file?
Goto Forum:
  


Current Time: Fri Apr 19 20:41:33 GMT 2024

Powered by FUDForum. Page generated in 0.03205 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top