지금 와일리를 보다가 나온건데, 콘솔이 아닌 다이얼로그로 입력, 출력하는법 발견,,

Call the static showInputDialog method of the JOptionPane class, and supply the string that prompts the input from the user. For example,
String input = JOptionPane.showInputDialog("Enter price:");
That method returns a String object. Of course, often you need the input as a number. Use the Integer.parseInt and Double.parseDouble methods to convert the string to a number:
double price = Double.parseDouble(input);
You can also display output in a dialog box:
JOptionPane.showMessageDialog(null, "Price: " + price);
Finally, whenever you call the showInputDialog or showMessageDialog method in a program that does not show any other frame windows, you need to add a line
System.exit(0);
to the end of your main method. The showInputDialog method starts a user interface thread to handle user input. When the main method reaches the end, that thread is still running, and your program won't exit automatically. To force the program to exit, you need to call the exit method of the System class. The parameter of the exit method is the status code of the program. A code of 0 denotes successful completion; you can use nonzero status codes to denote various error conditions.
                                                              (원문 출처 와일리,,,)

이 장에 의하면
JOptionPane.showInputDialog("Enter price:");
이 함수는 Enter Price:라는 문구가 들어간 입력 다이얼로그를 띄워주고 다이얼로그에서 확인이 눌리거나 엔터가 쳐질경우 그 값을 srting 형으로 반환합니다.
그 뒤 Double.parseDouble(string)이나 Int.parseInt(string)함수로 각각의 형으로 고칠수 있는것 같구요,,,,
근데 이거를 사용하면 main함수 마지막에
system.exit(0);을 꼭 써야 한다네요,,,

'대학생활 > JAVA' 카테고리의 다른 글

JAVA숙제,,,  (1) 2009.04.09
4주차 자바숙제 떳어요,,  (0) 2009.04.01
내맘대로 강좌 JAVA편 4  (0) 2009.03.25
내맘대로 강좌 JAVA편 3  (0) 2009.03.25
3주차 JAVA숙제가 나왔습니다^^  (2) 2009.03.23