| View previous topic :: View next topic |
| Author |
Message |
Rassman
Joined: 08 Sep 2009 Posts: 3
|
Posted: Tue Sep 08, 2009 1:14 pm Post subject: 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 |
|
 |
Nick Beare Posted via mailing list.
|
Posted: Wed Sep 09, 2009 5:19 pm Post subject: Name property not sticking |
|
|
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
|
Posted: Thu Sep 10, 2009 8:24 am Post subject: |
|
|
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.
|
Posted: Thu Sep 10, 2009 10:58 am Post subject: Name property not sticking |
|
|
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
|
Posted: Thu Sep 10, 2009 8:50 pm Post subject: |
|
|
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.
|
Posted: Fri Sep 11, 2009 2:26 am Post subject: Name property not sticking |
|
|
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.
|
Posted: Fri Sep 11, 2009 7:11 am Post subject: Name property not sticking |
|
|
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 |
|
 |
|