java界面运行部出来
这段代码是一个系统的一部分 运行出来应该是“支出添加”的界面import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class payAdd extends JInternalFrame implements ActionListener{
JTextField t1,t2,t3,t4,t5,t6,t7;
JButton bu1,bu2,bu3;
JComboBox cb;
JScrollPane sp;
payInfo a;
payAdd(String s1){
super(s1);
t1=new JTextField(3);
t2=new JTextField(3);
t3=new JTextField(3);
t5=new JTextField(3);
t4=new JTextField(8);
t6=new JTextField(10);
t7=new JTextField(10);
Container con1=this.getContentPane();
con1.setLayout(new BorderLayout());
JPanel p1=new JPanel(new FlowLayout());
JPanel p2=new JPanel(new FlowLayout());
ImageIcon img2=new ImageIcon("image/2.jpg");
JLabel e3=new JLabel(img2);
con1.add(e3,BorderLayout.NORTH);
p1.add(new JLabel("日期:"));
p1.add(new JLabel("年"));
p1.add(t1);
p1.add(new JLabel("月"));
p1.add(t2);
p1.add(new JLabel("日"));
p1.add(t3);
p1.add(new JLabel("序号"));
p1.add(t5);
p1.add(new JLabel("物品:"));
p1.add(t4);
String[] s={"学习类","饮食类","服装类","日常用品类","其他"};
cb=new JComboBox(s);
cb.setEditable(true);
p1.add(new JLabel("类型:"));
p1.add(cb);
p1.add(new JLabel("金额:"));
p1.add(t6);
p1.add(new JLabel("备注:"));
p1.add(t7);
p1.setBackground(Color.decode("#F6E3DD"));
con1.add(p1,BorderLayout.CENTER);
bu1=new JButton("保存并添加");
bu1.setBackground(Color.decode("#F6E3DD"));
bu1.setFont(new Font("Dialog",0,12));
bu2=new JButton("保存并关闭");
bu2.setBackground(Color.decode("#F6E3DD"));
bu2.setFont(new Font("Dialog",0,12));
bu3=new JButton("退出");
bu3.setBackground(Color.decode("#F6E3DD"));
bu3.setFont(new Font("Dialog",0,12));
bu1.addActionListener(this);
bu2.addActionListener(this);
bu3.addActionListener(this);
p2.add(bu1,BorderLayout.CENTER);
p2.add(bu2);
p2.add(bu3);
p2.setBackground(Color.decode("#F6E3DD"));
con1.add(p2,BorderLayout.SOUTH);
setBounds(350,290,345,265);
setVisible(true);
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setIconifiable(true);
setClosable(true);
setResizable(true);
setMaximizable(true);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==bu1){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:money");
Statement stat = conn.createStatement();
stat.executeUpdate("insert into 支出单 values('"+t1.getText()+""+t2.getText()+""+t3.getText()+"-"+t5.getText()+"','"+t1.getText()+"-"+t2.getText()+"-"+t3.getText()+"','"+t4.getText()+"','"+cb.getSelectedItem()+"','"+t6.getText()+"','"+t7.getText()+"')");
stat.close();
this.dispose();
payAdd a=new payAdd("支出添加");
}catch (Exception ex) {
System.err.println("异常:"+ex.getMessage());
}
}
else if(e.getSource()==bu2){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:money");
Statement stat = conn.createStatement();
stat.executeUpdate("insert into 支出单 values('"+t1.getText()+""+t2.getText()+""+t3.getText()+"-"+t5.getText()+"','"+t1.getText()+"-"+t2.getText()+"-"+t3.getText()+"','"+t4.getText()+"','"+cb.getSelectedItem()+"','"+t6.getText()+"','"+t7.getText()+"')");
stat.close();
this.dispose();
}catch (Exception ex) {
System.err.println("异常:"+ex.getMessage());
}
}
else if(e.getSource()==bu3){
this.dispose();
}
}
public static void main(String[] atgs){
new payAdd("12");
}
}