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.
[ BUILD # : 200904170201 ] [ JDK VERSION : 1.6.* ] I just tried creating a Java Desktop Application. Added a menu item. Set properties on the menu item and created an Action Handler. When I generated the Action Handler I noticed the name of the variable hadn't changed when I changed the name of the item in the GUI designer. Steps to reproduce: 1) Create a new Java Desktop App 2) Add a Menu Item to the File Menu before the Exit item 3) Set Properties for the Menu Item as follows: Name => fileOpenMenuItem mnemonic => VK_O text => Open label => Open 4) Select the menu item in the gui designer 5) From the pull-down menu, create the action handler for the ActionPerformed event. At this time I see the following method private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } What I should see is private void fileOpenMenuItemActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
This is a misunderstanding. The default name of the event-handler is not based on the value of the 'name' property. It is based on the variable name of the component. Note that your menu-item is still called jMenuItem1 in the source code. You should select the menu-item (for example in Inspector window) and change its variable name using 'Change Variable Name ...' action from the contextual menu.
Pardon my ignorance, but Huh?!?!?!? If I understand you correctly, the object in the GUI editor has a name that is different from it's name. So like Documents and Windows being two separate names used to identify the same thing (see #163174), here we have two separate names used to identify the same object. The difference being that here, I get to specify the name, but by changing it's name, we aren't changing it's name. We actually have to change the objects name in 2 separate locations. It gives me the impression that someone tried to normalize the data structure, but missed a major association. The default operation in other IDE's is that when you change the "Name" property, you are actually changing the "Name" of the instance (see IntelliJ's IDEA, Visual Studio, Borland's IDEs etc...) It's been a while, but I even remember doing something similar in Forte as far back as 1999-2000. Having two separate names for the object and requiring me to change the variable name outside of the properties is not a proper solution. In the words of Seth Godin, "This Is Broken!" At a minimum, there should be another property that is the Variable Name. A Better solution is to have a name change in the properties dialog trigger the Refactor code to change the Variable Name after asking the user for confirmation.
The word "name" is overloaded in this example. You use it for two completely different things: * name of the variable that represents the component in the code * value of the JavaBeans property of the component called 'name' e.g. value that is returned by getName() method There is no reason to force the same values of these two "names". Note that even you have at least two names: first name and surname. And I believe that you don't think that "someone missed a major association" by changing surname only (e.g. by not changing the first name) of the bride after wedding ;-). > At a minimum, there should be another property that is the Variable Name. Yes, there already is such a property. It is in the Code section of the Properties window.