• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Calculate button action code

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im new to Java , I don't know where to place the actionListener and actionEvents for the Calcbutton, any suggestions will be appreciated ?




 
Marshal
Posts: 80282
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I suggest you get rid of all those = null assignments. They are redundant. Make sure all those references are initialised in your constructor (or a private or final initGUI or similar method called from the constructor). It may be unnecessary to have that many components as fields. Also get rid of commented-out stuff from previous applications. Leaving old code in might make it easier to calculate Fahrenheit, but when you are trying to work out a mortgage, such old code is a potential source of errors.

I suggest you need to learn to write an anonymous class. I have written about them often enough: try here.
 
Campbell Ritchie
Marshal
Posts: 80282
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I keep trying to add code tags to your post, because it would look a lot better, but it doesn't seem to work. I think this thread would bit better on our GUIs forum, so I shall move it.
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic