Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with listener  RSS feed

 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i got a String variable named "valg" with the default value "i".

3 "if" statements for radiobuttons
and the last "if" statement for a JButton.

when the code have been through 1 of those 3 "if" statements,
the value of "valg" will change.

then again i press the JButton,
the value is still "i".
why is that?!
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you add the same instance of your listener to all the components

instead of adding a new instance to each one

This would make a difference since CTRL_Vis_StudInfo is holding state for valg.
 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello craig,
yes i did add the same instance.

but it doesnt work...
how comes??
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used the code from one of your earlier posts. Looks like you may have made some changes but this seems to work okay to illustrate the answer to your question. I changed the class names to avoid problems with name–clashing.
 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Craig Wood,

thank you for taking your time to answer my question!
really appreciate it. ^^

best regards,
kelvin
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!