Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Dialog I/O: Kilometers to Miles

This basic program asks the user for a number of miles and converts it to kilometers.

Tutorial Details:

This basic program asks the user for a number of miles and converts it to kilometers. It uses JOptionPane for all input and output.

Convert String to a number. We have to convert the input string into a number so that we can do the arithmetic with it. This conversion is done by calling Double.parseDouble. If we had wanted an integer instead of a double, we would have called Integer.parseInt.

Constant values are commonly declared static final before the methods are defined. The 'static' keyword will be explained later. If a variable is defined with the 'final' attribute, it's value can't be changed after an assignment to it, which is exactly what you want to do to prevent a constant from being changed.


 

Rate Tutorial:
http://www.roseindia.net/java/java-tips/examples-introductory/dialog/kmToMiles.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Dialog I/O: Kilometers to Miles

View Tutorial:
Dialog I/O: Kilometers to Miles

Related Tutorials:

Java Tip 72: Press Escape to close your Swing dialog windows
Java Tip 72: Press Escape to close your Swing dialog windows
 
Java Tip 85: Fun and games with JFileChooser - JavaWorld
Java Tip 85: Fun and games with JFileChooser - JavaWorld
 
Using XML and JSP together - JavaWorld March 2000
Using XML and JSP together - JavaWorld March 2000
 
Add a file finder accessory to JFileChooser - JavaWorld
Add a file finder accessory to JFileChooser - JavaWorld
 
Printing in Java, Part 2 - JavaWorld December 2000
Printing in Java, Part 2 - JavaWorld December 2000
 
Printing in Java, Part 3 - JavaWorld January 2001
Printing in Java, Part 3 - JavaWorld January 2001
 
Printing in Java, Part 4 - JavaWorld February 2001
Printing in Java, Part 4 - JavaWorld February 2001
 
Build secure network applications with SSL and the JSSE API - JavaWorld May 2001
Build secure network applications with SSL and the JSSE API - JavaWorld May 2001
 
Java security evolution and concepts, Part 5
Java security evolution and concepts, Part 5
 
Evolve your apps with the Phased Process pattern
Evolve your apps with the Phased Process pattern
 
Take command of your software
Take command of your software
 
SGLayout—a layout manager for the rest of us
SGLayout—a layout manager for the rest of us
 
Speed up your Swing GUI construction with better building blocks
Speed up your Swing GUI construction with better building blocks
 
Navigate through virtual worlds using Java 3D
Navigate through virtual worlds using Java 3D
 
Very interesting article
Very interesting article
 
Interesting ...
Interesting ...
 
Nice widget
Nice widget
 
JDemo: Interactive Testing Refactored
This article will introduce the JDemo framework and its techniques for writing code for interactive testing. It will also show the benefits that can be gained from writing demo code.
 
Sun Control Station 2.2 Administrator Manual
The Sun Control Station 2.2 software solution.
 
Creating Wizard Dialogs with Java Swing
Wizard dialogs are ubiquitous in today's desktop applications. This article creates a framework for a simple wizard dialog, complete with Back, Next, and Cancel buttons that you can extend for use in your applications as necessary.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.