📄 xaddframe.java
字号:
package bus;import javax.swing.*;import java.awt.*;import java.util.*;import javax.swing.table.*;import java.awt.event.*;public class XaddFrame extends JFrame { JTabbedPane jTabbedPane1 = new JTabbedPane(); JPanel pa1 = new JPanel(); JPanel pa2 = new JPanel(); JButton bt_save = new JButton(); JButton bt_del = new JButton(); JTable table=new JTable(); Vector head =new Vector(); DefaultTableModel model= new DefaultTableModel(); BusManager bm=new BusManager(); String vt; XaddFrame xf; public XaddFrame() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { this.getContentPane().setBackground(new Color(224, 224, 254)); this.setFont(new java.awt.Font("Dialog", 0, 16)); this.setSize(450,300); bt_save.setBackground(new Color(254, 231, 251)); bt_save.setFont(new java.awt.Font("Dialog", 0, 12)); bt_save.setPreferredSize(new Dimension(60, 25)); bt_save.setText("保存"); bt_del.setBackground(new Color(254, 231, 251)); bt_del.setFont(new java.awt.Font("Dialog", 0, 12)); bt_del.setPreferredSize(new Dimension(60, 25)); bt_del.setText("取消"); jTabbedPane1.setBackground(new Color(224, 224, 254)); jTabbedPane1.setFont(new java.awt.Font("Dialog", 0, 16)); pa1.setBackground(new Color(224, 224, 254)); pa1.setFont(new java.awt.Font("Dialog", 0, 16)); pa2.setBackground(new Color(224, 224, 254)); table.setFont(new java.awt.Font("Dialog", 0, 16)); this.getContentPane().add(jTabbedPane1, BorderLayout.CENTER); this.getContentPane().add(pa2, BorderLayout.SOUTH); pa2.add(bt_save, null); pa2.add(bt_del, null); jTabbedPane1.add(pa1, "维修记录信息"); JScrollPane sp=new JScrollPane(table); sp.getViewport().setBackground(new Color(224, 224, 254)); sp.setFont(new java.awt.Font("Dialog", 0, 16)); pa1.add(sp); head.add("ID"); head.add("车牌号"); head.add("维修类型"); head.add("维修时间"); head.add("维修天数"); head.add("维修记录"); head.add("维修地点"); head.add("维修费用"); model.setColumnIdentifiers(head); table.setModel(model); String s1="select * from ModJilu where ID='"+weixiu.wx+"'"; Vector mo=bm.selectBus(s1); model.setDataVector(mo,head); table.setGridColor(Color.pink); table.getTableHeader().setBackground(new Color(224, 224, 254)); table.getTableHeader().setFont(new Font("宋体",Font.PLAIN,16)); table.setRowHeight(30); table.setBackground(new Color(224, 224, 254)); table.setFont(new java.awt.Font("Dialog", 0, 16)); bt_save.addActionListener(new AL()); bt_del.addActionListener(new AL()); this.setVisible(true); } class AL implements ActionListener{ public void actionPerformed(ActionEvent e){ if(e.getSource()==bt_save){ 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()); Object id=model.getValueAt(row,0); String s="update ModJilu set Buspai='"+pai+"',ModNum='"+leix+"',ModTime='"+time+"',ModDay="+day+",ModJilu='"+jilu+"',Modplace='"+place+"',ModMon="+money+" where id="+id ; bm.updateBus(s); } if(e.getSource()==bt_del){ XaddFrame.this.dispose(); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -