目前我正在制作一款专注软件,但这里遇到运行时错误的是我的代码: -
public class gui015 extends JFrame {
private JTextField[] tf;
private JRadioButton a;
private JRadioButton b;
private JTextField t2;
private JOptionPane op;
private JButton c;
public gui015()
{
super("Attenedence");
setLayout(new FlowLayout());
t2 = new JTextField("Enter no. of students");
add(t2);
String s = t2.getText();
int a = Integer.parseInt(s);
tf = new JTextField[a];
while(a>0)
{
tf[a] = new JTextField();
add(tf[a]);
}
}
我得到了一堆这样的错误: -
Exception in thread "main" java.lang.NumberFormatException: For input string: "Enter no. of students"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at tutorial.gui015.<init>(gui015.java:26)
at tutorial.gui016.main(gui016.java:7)