• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with actionlistener and date

 
jeevansai jinne
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am wrting code for timezone converter applet but the problem is actionlistener code is converting time according to selected zone only firsttime when i use it later it was not converting.
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code won't compile as 'p' and 'l' are not declared variables - I guess they should be 'panel' and 'label'. Once changed to those names it works for me, every new timezone I entered changed the displayed time although I'm not convinced that manually entering a timezone via combobox is the best way to do this.

Other comments:
Variables should be declared as locally as possible so for example the variable 's' which is only used in the actionPerformed() method should be declared in that method rather than as an instance variable.
Instance variables should be declared as private unless there is a very good reason that they need wider visibility.
Class names should start with an upper case letter as per the Java Naming Convention.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic