• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

updating a textfield?

 
Rancher
Posts: 3376
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 when that window closes it goes back to undeclared


What does the state of a window have to do with the contents of a variable?  If the program is still running, it's variables will continue to hold data.

I assume that the code has updated the variable in the Student's object to save the new value of major.  Closing a window shouldn't change the contents of a Student object.
Is that assumption right? Does the code update the major in the Student object?
 
Saloon Keeper
Posts: 3293
146
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This topic goes on and on. I tried to import all of the code into my NetBeans, but I am missing some classes, and there is a lot of code snipping going on, so that didn't work. All We can do is guess the answers to your problems.

Can't you give a full listing, including everything?

Then:

Cody Biggs wrote:Well it does. The code gets the major name which is set to undeclared. Change the major textfield gets the new major, and sets it to majorName. but when that window closes it goes back to undeclared


Since the student is known here (is it?) why don't you simply do 'student.xxx(change)'   (set the new major here with the correct Student method).
 
Norm Radder
Rancher
Posts: 3376
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

it goes back to undeclared


That is the value when the class objects are initially created.  That value should never come back during a running program.  When existing objects are updated the value: "undeclared" is replaced with a new value.

How can the value go back to "undeclared"?  That says new objects are being created.  Why not continue using the existing objects?
 
Ranch Hand
Posts: 335
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:This topic goes on and on. I tried to import all of the code into my NetBeans, but I am missing some classes, and there is a lot of code snipping going on, so that didn't work. All We can do is guess the answers to your problems.

Can't you give a full listing, including everything?

Then:

Cody Biggs wrote:Well it does. The code gets the major name which is set to undeclared. Change the major textfield gets the new major, and sets it to majorName. but when that window closes it goes back to undeclared


Since the student is known here (is it?) why don't you simply do 'student.xxx(change)'   (set the new major here with the correct Student method).



Yep I’m an idiot. I was so focused on the two text fields I didn’t pay attention to anything else
 
Sheriff
Posts: 6029
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't feel like an idiot.  There are some difficult concepts discussed here.

Did you fix your problem, or do we need to get the Student back into the ListView in your main window?
 
Cody Biggs
Ranch Hand
Posts: 335
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes calling setMajor worked perfectly!
 
Piet Souris
Saloon Keeper
Posts: 3293
146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I agree with Knute: you're absolutely no idiot! See what you have achieved so far, certainly not beginners stuff, with the pleasant result of keeping us in a nice way off the street! Keep 'm coming, before you become a full blown java specialist!

A well deserved cow for all your efforts.
 
Cody Biggs
Ranch Hand
Posts: 335
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I appreciate that Knute and Piet. Of course being sick does not do me any favors. I have learned quite a bit from everyone here, and I appreciate everything y’all have done.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!