📄 xframe.java
字号:
package bus;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.sql.*;
import javax.swing.table.*;
class XFrame extends JFrame {
JTabbedPane TabPanel = new JTabbedPane();
JPanel pe1 = new JPanel();
JPanel pa = new JPanel();
JButton bt_save = new JButton();
JButton bt_del = new JButton();
Vector head=new Vector();
BusManager bm=new BusManager();
//JPanel jPanel1 = new JPanel();
DefaultTableModel model=new DefaultTableModel();
JTable table = new JTable();
BorderLayout borderLayout1 = new BorderLayout();
//ChepPanel cp;
public XFrame() {
this.setSize(300,300);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//public void XF(String s)
//{
//vt=s;
//}
private void jbInit() throws Exception {
bt_save.setFont(new java.awt.Font("Dialog", 0, 12));
bt_save.setPreferredSize(new Dimension(60, 25));
bt_save.setMargin(new Insets(2, 14, 2, 14));
bt_save.setText("保存");
bt_del.setFont(new java.awt.Font("Dialog", 0, 12));
bt_del.setPreferredSize(new Dimension(60, 25));
bt_del.setText("取消");
TabPanel.setBackground(SystemColor.activeCaptionBorder);
this.getContentPane().setBackground(Color.lightGray);
pe1.setBackground(Color.lightGray);
pa.setLayout(borderLayout1);
table.setDoubleBuffered(true);
table.setColumnSelectionAllowed(true);
this.getContentPane().add(TabPanel, BorderLayout.CENTER);
TabPanel.add(pa, "车票收入信息");
this.getContentPane().add(pe1, BorderLayout.SOUTH);
pe1.add(bt_save, null);
pe1.add(bt_del, null);
//****************************
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));
}
bt_del.addActionListener(new AL());
bt_save.addActionListener(new AL());
this.setTitle("票入修改信息");
JScrollPane sp=new JScrollPane(table);
pa.add(sp, BorderLayout.CENTER);
sp.getViewport().add(table, null);
head.add("ID");
head.add("车牌号");
head.add("出车时间");
head.add("收入金额");
model.setColumnIdentifiers(head);
table.setModel(model);
table.setGridColor(Color.pink);
table.getTableHeader().setBackground(Color.cyan);
String s1="select * from PiaoRu where ID='"+ChepPanel.ip+"'";
Vector mo=bm.selectBus(s1);
model.setDataVector(mo,head);
this.setVisible(true);
}
class AL implements ActionListener{
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bt_del) {
XFrame.this.dispose();
}
if (e.getSource() == bt_save) {
int row=table.getSelectedRow();
Object ID=model.getValueAt(row,0);
String pai=model.getValueAt(row,1).toString();
String time=model.getValueAt(row,2).toString();
String money=model.getValueAt(row,3).toString() ;
String s="update PiaoRu set BusPai='"+pai+"',InTime='"+time+"',InLiang='"+money+"' where ID="+ID;
System.out.println(s);
bm.updateBus(s);
System.out.println("更新成功");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -