publicclassStartupextendsJFrameimplementsActionListener{String[]DN1={"25","32","40","50","70","80","100"};JLabelDN1Label1=newJLabel("直径(mm)");JComboBoxDN1List=newJCombo...
public class Startup extends JFrame implements ActionListener{
String[] DN1={"25","32","40","50","70","80","100"};
JLabel DN1Label1 = new JLabel("直径(mm)");
JComboBox DN1List=new JComboBox(DN1);
String[] DN2={"25","32","40","50","70","80","100"};
JLabel DN2Label2= new JLabel("直径(mm)");
JComboBox DN2List=new JComboBox(DN2);
String[] t={"10","20","30","40"};
JLabel tLabel= new JLabel("水温(℃)");
JComboBox tList=new JComboBox(t);
public static void main(String[] args) {
new Startup().buildGUI();
}
public void buildGUI(){
JPanel topPanel=new JPanel();
DN1List.setEditable(true);
DN1List.addActionListener(this);
DN2List.setEditable(true);
DN2List.addActionListener(this);
tList.setEditable(true);
tList.addActionListener(this);
}
public void actionPerformed(ActionEvent arg0) {
int sint=25;
int sint2=25;
int sint3=10;
try {
sint = Integer.parseInt(DN1List.getSelectedItem().toString());
sint2 = Integer.parseInt(DN2List.getSelectedItem().toString());
sint3 = Integer.parseInt(tList.getSelectedItem().toString());
}catch (NumberFormatException ex) { return; }
double dj1,dj2,t;
switch (Integer.parseInt(DN1List.getSelectedItem().toString()))
{
case 25:
dj1=29;
break;
case 32:
dj1=36;
break;
case 40:
dj1=46;
break;
case 50:
dj1=58;
break;
case 70:
dj1=70;
break;
case 80:
dj1=84;
break;
case 100:
dj1=103;
break;
default:
dj1=sint*0.9654+6.1034;
break;
}
switch (Integer.parseInt(DN2List.getSelectedItem().toString()))
{
case 25:
dj2=29;
break;
case 32:
dj2=36;
break;
case 40:
dj2=46;
break;
case 50:
dj2=58;
break;
case 70:
dj2=70;
break;
case 80:
dj2=84;
break;
case 100:
dj2=103;
break;
default:
dj2=sint2*0.9654+6.1034;
break;
}
switch (Integer.parseInt(tList.getSelectedItem().toString()))
{
case 10:
t=10;
break;
case 20:
t=20;
break;
case 30:
t=30;
break;
case 40:
t=40;
break;
default:
t=sint3;
break;
}
double[] a={dj1,dj2,t,Double.parseDouble(l1Text.getText()),Double.parseDouble(l2Text.getText()),k,Double.parseDouble(z1Text.getText()),Double.parseDouble(z0Text.getText()),Double.parseDouble(p0Text.getText()),Double.parseDouble(p1Text.getText())};
程序太长,只贴了部分代码,它一直说
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
at java.lang.Double.parseDouble(Unknown Source)
还有等等unknown source
详见 http://zhidao.baidu.com/question/134498038.html
怎么改呢?
展开