Java actionPerformed and global variables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • creativeinspiration
    New Member
    • Jun 2007
    • 25

    Java actionPerformed and global variables

    Hi everybody,
    I have a question. In java I have a class which has global variables. Also, in this class I have an actionPerformed method implemented, which is called every time some event happens. Now, in actionPerformed , I set these variables. Although inside actionPerformed their values do appear to change, after it is finished, the values go back to their old ones. Why is this happening? How do I get the values to stay? Please help..
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    I don't know what you mean: Java does not have "global variables". The absolute best way to get help on a forum is to post a Short, Self Contained, Correct (Compilable), Example. Try that.

    SSCCE Explained

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by creativeinspira tion
      Hi everybody,
      I have a question. In java I have a class which has global variables. Also, in this class I have an actionPerformed method implemented, which is called every time some event happens. Now, in actionPerformed , I set these variables. Although inside actionPerformed their values do appear to change, after it is finished, the values go back to their old ones. Why is this happening? How do I get the values to stay? Please help..
      My blind guess is that you've defined local variables in your actionPerformed ()
      method having the same names as the static (not 'global') variables in your class.

      kind regards,

      Jos

      Comment

      Working...