🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #8453

Re: How to change color of text selectively ?

#8453
From: hrothenb
Date: Wed, 23 Aug 2000 00:00
31 lines
1609 bytes

To set the color of text in a JTextArea try:

         text = new JTextArea(20,40);
         getContentPane().add(text);
         text.append("this is red, and this is not.\n");
         text.setCaretPosition(0);
         text.setSelectionStart(6);
         text.setSelectionEnd(17);
         text.setSelectedTextColor(Color.red);
         text.setSelectionColor(Color.white);

In article <39A3E512.41163421@patni.com>,
  Vikas Chauhan <vikas.chauhan@patni.com> wrote:
> I wish to change the color of a keyword the moment it is typed in the
> JTextArea . I have made my  own document class extending PlainDocument
> and I am successfully able to trap the event that my keyword has been
> typed . But ...but... how do i change the color of that particular
word
> ? I did not find any way to selectively change the text color.
>
> Please help.
> thanking u in anticipation ...
> Vikas
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.
Technical Details
Message-ID: <8o0m6c$h2t$1@nnrp1.deja.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <39A3E512.41163421@patni.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,4cb68b7390a5ec27
X-Google-Attributes: gid111d45,public
From: hrothenb@bcpl.net
Subject: Re: How to change color of text selectively ?
Date: 2000/08/23
Message-ID: <8o0m6c$h2t$1@nnrp1.deja.com>
X-Deja-AN: 661542079
References: <39A3E512.41163421@patni.com>
X-Http-Proxy: 1.0 x54.deja.com:80 (Squid/1.1.22) for client 205.128.224.6
Organization: Deja.com - Before you buy.
X-Article-Creation-Date: Wed Aug 23 14:13:50 2000 GMT
X-MyDeja-Info: XMYDJUIDhrothenb
Newsgroups: borland.public.jbuilder.java.swing
X-Http-User-Agent: Mozilla/4.08 [en] (WinNT; U)