Java怎样写出Windows窗口化程序??

来源:百度知道 编辑:UC知道 时间:2024/06/05 22:54:06
代码是什么??高手给出来啊自学教程上没找到……

import javax.swing.JOptionPane;

class Test {
public static long function(int n)throws Exception{
if(n==0){
return 1;
}else{
return n*function(n-1);
}
}
public static void main(String[] args)throws Exception {
String whole=JOptionPane.showInputDialog("请输入一个整数!");
int n=0;
long l=0;
try{
n=Integer.parseInt(whole);

if(n<1)
throw new NumberFormatException();
}catch(NumberFormatException e){
JOptionPane.showMessageDialog(null, "您输入的不是一个正整数!");
}

l= function(n);
JOptionPane.showMessageDialog(null,l);
}
}