NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Name property not sticking

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
Rassman



Joined: 08 Sep 2009
Posts: 3

PostPosted: Tue Sep 08, 2009 1:14 pm    Post subject: Name property not sticking Reply with quote

I do appologise for this, I am sure the answer must be in this forum but I can not seem to get the right combination of search words to find it.

Using netbeans and java. When I set the name of a control I can not access it by it's name. For example

jTextField changed in properties to txtInput

I have to still use 'jTextField1' to access it in code.

I also tried to change the 'Accessible name', no idea what that is yet but I know it didn't let me access my control by name.

So, if I can't change the 'name' of a control in the properties list where can I change it?
Back to top
Nick Beare
Posted via mailing list.





PostPosted: Wed Sep 09, 2009 5:19 pm    Post subject: Name property not sticking Reply with quote

Take a look in the source code.
You could also then determine what changing the jTextField in properties
does.

Nick Beare



-----Original Message-----
From: Rassman [mailto:address-removed]
Sent: 08 September 2009 14:14
To: address-removed
Subject: [nbusers] Name property not sticking

I do appologise for this, I am sure the answer must be in this forum but
I can not seem to get the right combination of search words to find it.



Using netbeans and java. When I set the name of a control I can not
access it by it's name. For example



jTextField changed in properties to txtInput



I have to still use 'jTextField1' to access it in code.



I also tried to change the 'Accessible name', no idea what that is yet
but I know it didn't let me access my control by name.



So, if I can't change the 'name' of a control in the properties list
where can I change it?
Back to top
Rassman



Joined: 08 Sep 2009
Posts: 3

PostPosted: Thu Sep 10, 2009 8:24 am    Post subject: Reply with quote

That isn't an answer.

Why doesn't changing the 'name' property change the 'name' used in source code?
Back to top
Nick Beare
Posted via mailing list.





PostPosted: Thu Sep 10, 2009 10:58 am    Post subject: Name property not sticking Reply with quote

Not sure to be honest. I guess you don't really want to change a
property, but the identifier name (as you would in code).
I suppose the 'name' property has other uses (similar to other
properties). I vaguely recollect it has something to do with validation
messages.

If you were to debug your code and look at the .name property on the
component you would see that it had changed.

I always right click the component in the designer and then select
Change Variable name.

Nick Beare



-----Original Message-----
From: Rassman [mailto:address-removed]
Sent: 10 September 2009 09:24
To: address-removed
Subject: [nbusers] Name property not sticking

That isn't an answer.



Why doesn't changing the 'name' property change the 'name' used in
source code?
Back to top
Rassman



Joined: 08 Sep 2009
Posts: 3

PostPosted: Thu Sep 10, 2009 8:50 pm    Post subject: Reply with quote

This seems to mean that all netbeans users have code that can only use the default names-

jTextField1.setText(str)
jTextField2.setText(str)
jTextField10.setText(str)
jTextField11.setText(str)

Now what did I have in jList7 again?

I can't believe that,
Back to top
Mark Wade
Posted via mailing list.





PostPosted: Fri Sep 11, 2009 2:26 am    Post subject: Name property not sticking Reply with quote

On Sep 10, 2009, at 4:24 AM, Rassman wrote:

Quote:
That isn't an answer.



Why doesn't changing the 'name' property change the 'name' used in
source code?


I'm not really sure what this is about because you haven't quoted what
your referring to, though Nick Beare's response clues me in somewhat,
and your complaint:

Quote:
This seems to mean that all netbeans users have code that can only
use the default names-


jTextField1.setText(str)

jTextField2.setText(str)

jTextField10.setText(str)

jTextField11.setText(str)


Now what did I have in jList7 again?


I can't believe that,


offers another clue,

If you want meaningful names for your fields and buttons and other
widgets and such, as Nick Beares suggests, right click on the widget
and select "Change variable name..." or select or use the Refactor
menu and choose "Rename..." Then jTextField1.setText(str will become
MyMeaningfulTextFieldName.setText(str).

The name property is used in the set and getName() methods and has
nothing to do with the variable name. What's it good for and why is
it used? I'm not sure, I think I've used it a couple of times. I'd
be interested in the answer, though it's a java one, not a NetBeans one.

Mark Wade
address-removed
Back to top
Mike Riley
Posted via mailing list.





PostPosted: Fri Sep 11, 2009 7:11 am    Post subject: Name property not sticking Reply with quote

Mark Wade wrote:
Quote:
If you want meaningful names for your fields and buttons and other
widgets and such, as Nick Beares suggests, right click on the widget and
select "Change variable name..." or select or use the Refactor menu and
choose "Rename..." Then jTextField1.setText(str will become
MyMeaningfulTextFieldName.setText(str).

I do that as soon as I create them in the Design section, so they have
meaningful names from the start, before I start slinging any code.
Otherwise, you never will know which numbered object is what later on.

Mike
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo