报 java.lang.NumberFormatException: For input string: ""异常怎么解决
import java.awt.TextField;import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import
import java.util.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
//界面实现
public class CaiPiao extends JFrame {
JTextField jf = new JTextField(20);
public CaiPiao(){
super("双色球");
setSize(300,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
JTextField jf = new JTextField(20);
JTextArea ja = new JTextArea(15,20);
JLabel jl1 = new JLabel("彩票注数");
JLabel jl2 = new JLabel("彩票号码");
JPanel jp = new JPanel();
JButton jb1 = new JButton("输出");
JButton jb2 = new JButton("清空");
jp.add(jl1);
jp.add(jf);
jp.add(jl2);
jp.add(ja);
jp.add(jb1);
jp.add(jb2);
BTActionListener bt = new BTActionListener(this);
jb1.addActionListener(bt);
jb2.addActionListener(new ClcActionListener(this));
setContentPane(jp);
show();
}
public static void main(String[] args) {
CaiPiao cp = new CaiPiao();
ShengCheng sc = new ShengCheng();
System.out.println(sc.creat());
}
}
//输出按钮监听器
class BTActionListener implements ActionListener{
CaiPiao cp =null ;
public BTActionListener(CaiPiao cp){
this.cp = cp;
}
public void actionPerformed(ActionEvent arg0) throws NumberFormatException {
ShengCheng sc = new ShengCheng();
int lo = Integer.parseInt(cp.jf.getText());
for(int i=0;i<lo;i++){
System.out.println(sc.creat());
System.out.println("test !");
}
}
}