星期一, 10月 16, 2006

Lab window input dialog

Use the following command to generate a window input dialog

String myString=JOptionPane.showInputDialog("Enter a number: ");

use the following command to convert a string to a number

int myNumber = Integer.parseInt(myString);

and finally use the following command to print the input number to the console

System.out.println("The number is "+ myNumber);

Don't forget the following import command

import javax.swing.JOptionPane;

so that Java can recognize JOptionPane library.

1 則留言:

keleven 提到...
網誌管理員已經移除這則留言。