This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 25866 - Hardcoded color resources in search dialog
Summary: Hardcoded color resources in search dialog
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Search (show other bugs)
Version: 3.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: issues@utilities
URL:
Keywords: UI
Depends on:
Blocks: 25472
  Show dependency tree
 
Reported: 2002-07-22 10:47 UTC by Jesse Glick
Modified: 2003-02-04 14:58 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2002-07-22 10:47:18 UTC
Changing NbTheme to use different colors
throughout the IDE does not work properly in the
text field of the Search Filesystems dialog.
Culprit seems to be
org.netbeans.modules.search.types.TextCustomizer
which hardcodes Color.black and Color.red as the
foreground colors for regexpTextField and
substringTextField. You should not do this, as it
does not work e.g. if someone sets text fields to
be white on black!

Please use UIManager.getColor for looking up the
proper colors. "TextField.foreground" should be
used rather than Color.black. For replacing
Color.red, you should probably define your own
key, e.g. "TextField.errorForeground", and supply
a default value (red) if none is set in the UI
defaults; themes could then override it sensibly.
Comment 1 _ lkramolis 2002-09-09 10:37:51 UTC
How I can set default value for "TextField.errorForeground" from
module side? Thanks.
Comment 2 _ tboudreau 2002-09-09 13:06:47 UTC
UIManager.getDefaults().put ("TextField.errorForeground", myColor)

But don't do this unless the value is null!  Theme support allows the
default theme file to define this color (or whatever) in UIDefaults.

What I would suggest is, somewhere when you initialize the component, do:

errorForeground=UIManager.getDefaults().get("TextField.errorForeground");
if (errorForeground == null) {
   errorForeground = Color.red;
   }

or something like that.  It would be bad form for modules to
put things in UIDefaults - other modules could clobber the
setting, and it would be very hard to track down.
Comment 3 _ lkramolis 2002-09-09 15:36:59 UTC
Fixed in main trunk.

http://utilities.netbeans.org/servlets/ReadMsg?msgId=375875&listName=cvs

Is there some common way how to "publish" module's defined keys?
Comment 4 _ tboudreau 2002-09-10 10:44:17 UTC
We're going to need away, if the patches I'm putting together for
fixing borders get accepted.  So far I've defined (subject to change -
I'm still working on it) about 6 - cases like the MiniStatusBar border
and the focus indicating border on the maximized MDI window.

Given that NbTheme.java seems to be the entry-point for this, probably
the best bet is to define some static constants on it - that way the
info is all kept in the same place.

Comment 5 Jesse Glick 2002-09-10 18:00:36 UTC
"Given that NbTheme.java seems to be the entry-point for this,
probably the best bet is to define some static constants on it - that
way the info is all kept in the same place." - please do not put any
resource names used only in modules into core. No no. If we actually
need registration for the defaults (is it really necessary?) there
should be some sort of simple declarative registration mechanism using
layers (something very fast to parse, since it will have to be done
during startup).
Comment 6 Jesse Glick 2002-09-10 18:01:22 UTC
BTW don't forget to set target milestones when fixing bugs...
Comment 7 _ lkramolis 2002-09-11 07:30:32 UTC
"If we actually need registration for the defaults (is it really
necessary?) ..." - I do not need to register default value, but I
think the used key should be known for themes.xml writers to know all
used keys in NB.
Comment 8 _ tboudreau 2002-09-11 11:02:20 UTC
Yes, true, registering it is not hugely useful.  My only worry is that
it will end up like the various startup line switches for NetBeans, or
things you can do with putClientProperty() in the window system, where
they are not documented anywhere, and the only way to figure them out
is to grep the entire codebase.  If all of these are defined as fields
on one class, you have a registry of the information.  Where it should
live, I don't know.

"I do not need to register default value, but I
think the used key should be known for themes.xml writers to know all
used keys in NB."

Fine, but will they know?  And how will they find out?