Forum Stats

  • 3,873,041 Users
  • 2,266,499 Discussions


resourceMap returning null

843810 Member Posts: 46,938
edited Jul 21, 2010 1:47AM in Java Desktop Applications
Product Version: NetBeans IDE 6.8 (Build 200912041610)
Java: 1.6.0_17; Java HotSpot(TM) Client VM 14.3-b01

Hello, I have been having some problems building a GUI for a desktop application in netbeans:

my current GUI works great, everything is appearing correctly.

when I update the GUI by adding a new label from the toolbox onto my form, and use the netbeans preview function, everything looks great

however when i run the application the new label has disappeared..

to try and understand the problem i ran the app in debug mode and stepped through the auto-generated initComponents() code

from debugging i believe the problem comes from this line of code:
TEST_lbl.setText(resourceMap.getString("TEST_lbl.text")); // NOI18N

when this line of code has executed TEST_lbl.setText is equal to null..

so the label is disappearing when i run the app because it has no text value to display...

i opened the resource map file in note pad (.properties file) and it contains an entry "TEST_lbl.text=jLabel1" among the entries for all the other working controls...

so the properties file has the correct value, but resourceMap.getString is not retrieving it

i can work around this problem by changing the "Automatic Resource Management" option of the form from "All Resources" to "Off"

this changes the auto-generated setText code line to: TEST_lbl.setText("jLabel1"); and makes the label display correctly when the application runs

my first question is, is this a known bug? or have i done something silly and accidently changed a setting some ware?

if this is not a bug, how do i correct the problem without changing the resource management setting?

if this is a bug, what are the implications of turning off automatic resource management?

Thanks for the help, - Gaz


  • 843810
    843810 Member Posts: 46,938
    Do you have multiple resource map files for different locales?
    e.g. , (with would be for German)?
    Maybe the TEST_lbl.text entry is only in the file, but missing in the file for the locale you're using
  • 843810
    843810 Member Posts: 46,938
    If you are not using different locales in your application then turn off this feature to pick the value from resource file.
    For doing so go to properties of that component > Text (if its JLabel) > Detailed view ( by clicking on .... ) >on this from you'll find a checkbox for "Define as Resource"
    You need to uncheck that. This will make your application to pick a fixed value that you have set as Text for your JLabel.

    In your case , problems sees to be either with resource file i.e. properties file or resource value set inside that file.
    You can even set desired value to be picked from resource file on same location mentioned above.

    Plz get back for any doubts.

    Mahesh Kedari
    Fidus Technologies Ltd.
  • PhHein
    PhHein Member, Moderator Posts: 7,254 Silver Trophy
    Don't advertise for your company please.
  • 843810
    843810 Member Posts: 46,938
    I just ran into a similar problem - this helped because I wasn't aware of the properties file.

    It seems that it wasn't until I did a clean build that netbeans decided to copy over the updated properties file ......
  • 843810
    843810 Member Posts: 46,938
    I am having the same problem. Latest everything, and it seems to have only started in the past day or so. To echo the OP, is this a bug or have I turned something off I shouldn't have?
  • darrylburke
    darrylburke Member Posts: 18,007
    1. This problem appears to be related to the NetBeans IDE and is off topic for this forum.

    2. The response at #5 appears to be the correct answer.

    3. I'm locking this thread. Any further NetBeans related questions may please be asked on a NetBeans forum (no, there isn't one here -- search the net).

This discussion has been closed.