class statPanel extends JPanel implements ActionListener {
private ImageIcon m = new ImageIcon("image/hex.JPG");
private JLabel JL = new JLabel("上件统计", SwingConstants.CENTER);
private JLabel jlb = new JLabel();
private JLabel jla_date = new JLabel("日期:大于");
private JLabel jla_to = new JLabel("小于:");
private JLabel jla_model = new JLabel("型号:");
private JTextField jtf_date = new JTextField();
private CalendarPanel p = new CalendarPanel(jtf_date, "yyyy/MM/dd");
private JTextField jtf_to = new JTextField();
private CalendarPanel p2 = new CalendarPanel(jtf_to, "yyyy/MM/dd");
private String[] a={"E210","E240","E360"};
private JComboBox jtf_model = new JComboBox(a);
private JButton query = new JButton("查询");
private JButton export = new JButton("导出");
private JTable table = new JTable(3,4);
private JPanel contentPane=new JPanel();
private JScrollPane scrollPane = new JScrollPane();
private JdbcUtil ut = new JdbcUtil();
private Vector v_1=new Vector();
private LocalTableModel mod = new LocalTableModel();
public statPanel() {
this.addListener();
initialFrame();// 初始化界面
}
private void initialFrame() {//界面构造
p.initCalendarPanel();
p2.initCalendarPanel();
jlb.setLayout(null);
// 将控件添加到容器相应位置
this.JL.setBounds(140, 0, 250, 40);
this.jlb.add(JL);
this.JL.setFont(new Font("宋体",1,30));
this.jlb.add(new JLabel().add(p));
this.jlb.add(new JLabel().add(p2));
this.jla_date.setBounds(5, 50, 55, 25);
this.jlb.add(jla_date);
this.jtf_date.setBounds(60, 50, 80, 25);
this.jtf_date.setEnabled(false);
this.jtf_date.setFont(new Font("宋体",1,12));
this.jlb.add(jtf_date);
this.jla_to.setBounds(145, 50, 30, 25);
this.jlb.add(jla_to);
this.jtf_to.setBounds(175, 50, 80, 25);
this.jtf_to.setEnabled(false);
this.jtf_to.setFont(new Font("宋体",1,12));
this.jlb.add(jtf_to);
this.jla_model.setBounds(265, 50, 40, 25);
this.jlb.add(jla_model);
this.jtf_model.setBounds(305, 50, 60, 25);
this.jlb.add(jtf_model);
this.query.setBounds(375, 50, 60, 25);
this.jlb.add(query);
this.export.setBounds(445, 50, 60, 25);
this.jlb.add(export);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(5,80,530,300);
this.jlb.add(scrollPane);
table = new JTable(mod);
scrollPane.setViewportView(table);
//jlb.setIcon(m);
this.add(jlb);
setVisible(true);
}
private void addListener() {//添加监听器
this.query.addActionListener(this);
this.export.addActionListener(this);
this.jtf_date.addActionListener(this);
this.jtf_to.addActionListener(this);
this.jtf_model.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {//监听器
if(e.getSource()==query){
System.out.println("query ");
int a=jtf_date.getText().compareTo(jtf_to.getText());
if(a>0){
JOptionPane.showMessageDialog(this,"第2个日期应该>=第1个!","提示",
JOptionPane.INFORMATION_MESSAGE );
return;
}
List list = this.querySelect();
System.out.println("写入表格前"+list.size());
for(int i = 0;i<list.size();i++){
Frame frame = (Frame)list.get(i);
System.out.println("date "+frame.getDate()+"shift "+frame.getShift()+"number "+frame.getNumber()+"note "+frame.getNote());
mod.addRow(new Object[]{frame.getDate(),frame.getShift(),frame.getNumber(),frame.getNote()});
}