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.
If I set the background color of a JTextArea to Label.background, the property editor shows a swatch of the color with Label.background as the text. However, if I create a JLabel and don't edit the background color at all, the property sheet shows 204,204,204 as the text next to the swatch. I think it should show Label.background. I'm not sure whether the drop down choices should automatically change to the swing palette too. Maybe they shouldn't until the user explicitly chooses a color from that palette.
This not possible - there is no unambiguous way how to get UI manager color strings from RGB values. If you choose the color from the Swing palette in ColorEditor, a special color object is created which contains additional info about the color. But i JLabel and other components, there's just a simple java.awt.Color.
There has been discussion about this issue on nbui and HIE people have determined that the idea has merit and should be for the 4.0 timeframe. Please see the thread at <http://www.netbeans.org/servlets/BrowseList?listName=nbui&by=thread&from=9155>
Well, I don't say the idea is wrong. I just don't know how this could be implemented... The only thing I can imagine is to duplicate the ColorEditor from core in form module and tweak it somehow. But then we will have two almost same property editors, one working only for forms? So I don't know...
The first thing to do is to decide what is desired. After that we can decide if the solution is form specific or should be used for all color editors. I see 2 possibilities: 1) Use the standard (core) property editor as a PropertyPanel solution and do something special in form. 2) Make a change to the core property editor.
I'm talking about the case, when something like "label.background" should be displayed for color that *has not been changed*. This is the desired behaviour, isn't it? But there's no way (or I don't know about any), how to tell the ColorEditor from core (which displays the color) that certain color is a label's background - ColorEditor receives only Color object with e.g. [204,204,204] - so it cannot know it is just "label.background" and not "button.background" or something completely different. I'll investigate this further if PropertyEnv could not be used somehow ... but it definitely cannot be solved in ColorEditor only.
I understand. I'm sure David will be open to adding more hints to the core editor if it is necessary. Let's wait and see what the desired behavior is.
I think this is just an enhancement request, not defect.
Created attachment 13531 [details] Stact trace
I am sorry, the attachment does not belong to the issue.
After more than 3 years I still don't see a way how this could be done. I think the fact that JLabel background is shown as [212,208,200] is now rather minor issue - as the property clearly communicates that the value was not set (changed). The thing that is important here is how to make the user choose the colors from the symbolic palettes (i.e. Swing palette mainly) so they don't specify hardcoded colors (that would not match on different platform/look&feel), but colors that are obtained from UIManager table via a key. So e.g. if the user wants a textfield with "grey" background, they should not choose [212,208,200] as this is only Windows color, but they should choose Swing Palette -> Panel.background, which will generate code like: jTextField1.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background")); which will provide the correct color on all platforms.