🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Inversed text in JTextPane

#8835
From: Paul Furbacher [TeamB]
Date: Mon, 17 Jul 2000 00:00
30 lines
1816 bytes
Jeroen Zwartepoorte wrote:

> I need to have some piece of text show up "inversed" in my JTextPane
> (Background color = foreground and foreground = background).
> 
> To accomplish this i've written the following code:
> 
> SimpleAttributeSet fAttr = new SimpleAttributeSet();
> 
>                     StyleConstants.setBackground(fAttr, Color.black);
>                     StyleConstants.setForeground(fAttr, Color.blue); // use
> blue here, easier to see than white during debugging.
> 
> The above code does NOT have the desired effect: the Foreground attribute
> overrides the background attribute: the entire region of the text is blue.
> Now, if i comment the setBackground method, the text is correctly colored,
> and the background is still white (as it was originally).
> 
> What am i doing wrong here???
> 
> [...](this stuff is a bit too advanced for most people).

For this "advanced" stuff, you might benefit from reading Kim
Topley's "Core Java: advanced programming."  (Topley has written
several "Core Java" titles.)  He devotes a good number of chapters
in the first half of the book to increasingly advanced text 
manipulation in Java and definitely covers you question.


Paul Furbacher (TeamB)
Technical Details
Message-ID: <3973C20B.1AD68AA2@home.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8kv4ee$50e4@bornews.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,827bfd654b83f85d
X-Google-Attributes: gid111d45,public
From: "Paul Furbacher [TeamB]" <pnf@home.com>
Subject: Re: Inversed text in JTextPane
Date: 2000/07/17
Message-ID: <3973C20B.1AD68AA2@home.com>
X-Deja-AN: 647581587
Content-Transfer-Encoding: 7bit
References: <8kv4ee$50e4@bornews.borland.com>
X-Accept-Language: en,pdf
Content-Type: text/plain; charset=us-ascii
Organization: Reverse Alchemy, Inc.
Mime-Version: 1.0
Reply-To: pnf@home.com
Newsgroups: borland.public.jbuilder.java.swing