| Author |
Netbeans IDE question: Named objects
|
Steve Schowiak
Greenhorn
Joined: Oct 21, 2002
Posts: 20
|
|
I am applying a name to a component, i.e. a jTextField and name it so: "myTextField" in the property sheet. I am checking to make sure the setName method for the textfield has been invoked and it has. So now, I should be able to reference the object as 'myTextField.somemethod()', right? Later in the code I refer to the jtextfield like so: myTextField.setText("blah blah blah"). The compiler give a 'cannot resolve symbol' error. When I use the given name 'jTextField1' for that object, everything works OK. I would like to give meaningful names to my objects, rather than use 'jTextField1' and so on. What am I doing wrong?
|
I am not insane. The voices in my head told me so.
|
 |
Gregg Bolinger
Sheriff
Joined: Jul 11, 2001
Posts: 15040
|
|
The setName() method has nothing to do with how you call methods on that object. If you are using Netbeans 3.5 (not sure if this is the same in earlier version) on the properties sheet there is a tab called Code Generation. The last field on that list says Variable Name. This is what you will want to change. It took my 5 minutes just to find that property in Netbeans. Putting that value on that tab (having tabs in general for the property sheet) is just plain dumb in my opinion. But anyway, that will actually change the variable name in the code so you can call the methods using your own variable name. Interesting question...If you are just learning programming, I would highly recomend not using a GUI Builder. You won't know what you are doing behind the scenes which is very important when learning.
|
My Blog | DZone Articles
|
 |
Sonny Pondrom
Ranch Hand
Joined: Jun 05, 2001
Posts: 128
|
|
|
That is good advice about not using the GUI until you know it well enough. How do you know when you know it well enough? Can you think of any questions you could ask yourself?
|
 |
Steve Schowiak
Greenhorn
Joined: Oct 21, 2002
Posts: 20
|
|
I am an experienced systems programmer, currently not employed in my field. No jobs for mainframe/COBOL programmers anymore. I've taken a course in Java programming and taught C++ in a private college before. I have the essentials of Java down fairly well (I think), it's just the nitty-gritty, GUI, objected-oriented stuff that throws me for a loop sometimes. I use the visual IDE because I like the convenience of the drag/drop assembly of the GUI portion of Java. Don't have to full around with x-y coordinates, size of components, positioning, etc., and allows me to concentrate on the logic. Just double-click on a component, and an event object is generated, and I just fill in the rest of the logic. It also guards against typos, which I am famous for. IDE's are project oriented, which is nice when you have several classes involved. I am weak and lazy, I must admit, but RAD is the way to go for me! Now I must digress. I found that if you right-clicked on the the name of the component in the component browser, you can change the actual name. Ahhh, sheeezzz ... Thanks all, for your support!  [ September 24, 2003: Message edited by: Steve Schowiak ]
|
 |
 |
|
|
subject: Netbeans IDE question: Named objects
|
|
|