aspose file tools*
The moose likes Beginning Java and the fly likes Temperature Converter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Temperature Converter" Watch "Temperature Converter" New topic
Author

Temperature Converter

David Coello
Greenhorn

Joined: Jun 05, 2012
Posts: 22
Hello forum members,

I am a new java developer. I have been working on a Converter from Farenheit to Celsius with the push of a button. I programmed it under those specs, but I would like to program that same button to convert back to celsius. I appreciate your comments, basically if a button can perform 2 actions, convert from Fahrenheit to Celsius and Celsius to Farenheit.


Thank you.

David

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30293
    
150

Yes, the same button can do two things. You'd need an instance variable to remember which state the button is in so you know which label to display and which action to perform.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
check which textfield is empty, via .equals(""), ensuring both are not empty,
then convert the non-empty for display in the empty
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Temperature Converter