⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 weixiu.java~15~

📁 cs结构的一个公交车系统好有使用价值啊下吧--- --- ---
💻 JAVA~15~
字号:
package bus;import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.util.*;import java.sql.*;import javax.swing.table.*;public class weixiu extends JPanel {  JPanel pe1 = new JPanel();  JPanel pe2=new JPanel();  JButton bt2=new JButton("增加");  JButton bt3=new JButton("删除");  JButton bt4=new JButton("修改");  JButton bt5=new JButton("取消");  BorderLayout borderLayout1 = new BorderLayout();  JLabel le1 = new JLabel();  JComboBox Box1 = new JComboBox();  JButton bt1 = new JButton();  JTable table=new JTable();  Vector head=new Vector();   DefaultTableModel model=new  DefaultTableModel();   BusManager bm=new BusManager();  JButton bt_save = new JButton();  static String wx; weixiu() {    try {      jbInit();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  public void jbInit() throws Exception {    this.setLayout(borderLayout1);    le1.setFont(new java.awt.Font("Dialog", 0, 14));    le1.setText("请输入查询车辆:");    bt1.setBackground(SystemColor.info);    bt1.setFont(new java.awt.Font("Dialog", 0, 12));    bt1.setPreferredSize(new Dimension(60, 25));    bt1.setText("查询");    Box1.setBackground(SystemColor.info);    Box1.setPreferredSize(new Dimension(150, 22));    Box1.setRequestFocusEnabled(true);    Box1.setPopupVisible(false);    bt2.setBackground(SystemColor.info);    bt2.setFont(new java.awt.Font("Dialog", 0, 12));    bt2.setPreferredSize(new Dimension(60, 25));    bt3.setBackground(SystemColor.info);    bt3.setFont(new java.awt.Font("Dialog", 0, 12));    bt3.setPreferredSize(new Dimension(60, 25));    bt4.setBackground(SystemColor.info);    bt4.setFont(new java.awt.Font("Dialog", 0, 12));    bt4.setAlignmentY((float) 0.5);    bt4.setPreferredSize(new Dimension(60, 25));    bt4.setFocusPainted(true);    bt5.setBackground(SystemColor.info);    bt5.setFont(new java.awt.Font("Dialog", 0, 12));    bt5.setPreferredSize(new Dimension(60, 25));    bt_save.setBackground(SystemColor.info);    bt_save.setFont(new java.awt.Font("Dialog", 0, 12));    bt_save.setPreferredSize(new Dimension(60, 25));    bt_save.setFocusPainted(true);    bt_save.setText("保存");    this.setFont(new java.awt.Font("Dialog", 0, 16));    this.setForeground(SystemColor.window);    pe1.setBackground(new Color(234, 204, 255));    pe1.setForeground(SystemColor.info);    pe2.setBackground(new Color(234, 204, 255));    pe2.setForeground(SystemColor.window);    pe1.add(le1, null);    this.add(pe1, BorderLayout.NORTH);    pe1.add(Box1, null);    pe1.add(bt1, null);    JScrollPane sp=new JScrollPane(table);    this.add(sp,"Center");    pe2.add(bt2);    pe2.add(bt_save, null);    pe2.add(bt3);    pe2.add(bt4);    pe2.add(bt5);    this.add(pe2,"South");    head.add("ID");    head.add("车牌号");    head.add("维修类型");    head.add("维修时间");    head.add("维修天数");    head.add("维修记录");    head.add("维修地点");    head.add("维修费用");    model.setColumnIdentifiers(head);    table.setGridColor(Color.pink);    table.getTableHeader().setBackground(new Color(234, 204, 255));    Box1.addItem("全部");   Vector no=new Vector();   no=bm.selectBus("select BusPai from BusGuanli");   for(int i=0;i<no.size();i++)   {     Vector vt=new Vector();     vt=(Vector)no.get(i);     Box1.addItem(vt.get(0));   }    table.setModel(model);    bt1.addActionListener(new AL());    bt2.addActionListener(new AL());    bt3.addActionListener(new AL());    bt4.addActionListener(new AL());     bt_save.addActionListener(new AL());  }  //**************************************  class AL implements ActionListener{      public void actionPerformed(ActionEvent e){         if(e.getSource()==bt1){            String name=Box1.getSelectedItem().toString();            if(name.equals("全部"))          {            String s="select * from ModJilu";            Vector one=bm.selectBus(s);            model.setDataVector(one,head);          }          else          {            String s="select * from ModJilu where BusPai='"+name+"'";            Vector one=bm.selectBus(s);            model.setDataVector(one,head);          }         }         if(e.getSource()==bt2){           model.addRow(new Vector());           //String s="insert into ModJilu(Buspai) values('')";          // bm.updateBus(s);         }         if(e.getSource()==bt3){           int row=table.getSelectedRow();           if(row<0)             return;           String obj=model.getValueAt(row,0).toString();           int a=Integer.parseInt(obj);           String s="delete from ModJilu where id="+obj;           System.out.println(obj);           System.out.println(s);           bm.updateBus(s);           model.removeRow(row);           System.out.println("删除成功");          }         if(e.getSource()==bt_save){           System.out.println("jsdkfjeklwjfk");           int row=table.getSelectedRow();           String pai=model.getValueAt(row,1).toString();           String leix=model.getValueAt(row,2).toString();           String time=model.getValueAt(row,3).toString();           int day=Integer.parseInt(model.getValueAt(row,4).toString());           String jilu=model.getValueAt(row,5).toString();           String place=model.getValueAt(row,6).toString();           double money=Double.parseDouble(model.getValueAt(row,7).toString());           System.out.print(money);           String id=model.getValueAt(row,0).toString();          // String s="insert into PiaoRu (BusPai,InTime,InLiang) values('"+pai+"','"+time+"','"+money+"')";          //String s="update ModJilu set Buspai=,ModNum=,ModTime='"+time+"',ModDay='"+day+"',ModJilu='"+jilu+"',Modplace='"+place+"',ModMon='"+money+"' where id="+id ;       String s="insert into ModJilu (BusPai,ModNum,ModTime,ModDay,ModJilu,ModPlace,ModMon) values('"+pai+"','"+leix+"','"+time+"',"+day+",'"+jilu+"','"+place+"',"+money+")";       bm.updateBus(s);         }         if(e.getSource()==bt4){           int row=table.getSelectedRow();           wx=model.getValueAt(row,0).toString();           new XaddFrame();         }      }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -