This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with actionlistener and date  RSS feed

 
jeevansai jinne
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.
 
Tony Docherty
Saloon Keeper
Posts: 3214
78
  • 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
Boost this thread!