🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #3003

no effect after setForeground() on Label ...

#3003
From: Nick Lee
Date: Mon, 22 Jun 1998 00:00
53 lines
1794 bytes
Hi,

   I have a Label object in a panel. I want to achieve the effect that
when the mouse moves

over the Label, the color of the Label will change.

Following is the code (this is still JDK1.0 code):

--------------------------------

public void mouseMove(Event e, int x, int y)
{
   // find the component the mouse is on
   Component c = this.locate(x, y);
   if (c instanceof Label)
   {
      Label b = (Label)c;
      b.setForeground(Color.yellow);
   }
   return true;
}

---------------------------------

But the label just doesn't change color. I try to put b.repaint() after
setting the
foreground,
but the label will be covered up by a rectangle with the same size as
the label itself. (I
guess it's repainting, but not repainting the text).

But if I b.setText() after setting the foreground, then the Label redraw
with the new
foreground color.

It seems like there's no way to get it to redraw with the new color
unless you change the
text at the same time.

I've also tried to subclass Label and override mouseEnter() to achieve
the same effect, but

the result is the same. i.e. nothing happen if just setForeground();
rectangle if repaint()
..............

    anyone knows the solution to this?


Thanks a lot,
Nick
Technical Details
Message-ID: <358E16C6.F7818F21@unixg.ubc.ca>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,49781249d0acc79a,start
X-Google-Attributes: gid1089d0,public
From: Nick Lee <leenick@unixg.ubc.ca>
Subject: no effect after setForeground() on Label ...
Date: 1998/06/22
Message-ID: <358E16C6.F7818F21@unixg.ubc.ca>
X-Deja-AN: 364914018
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.api