Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

problem with actionlistener and date

Ranch Hand
Posts: 62
  • 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.
Posts: 3323
  • 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.
The knights of nee want a shrubbery. And a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic