java课程设计----图书馆管理系统(6)
发布时间:2021-06-05
发布时间:2021-06-05
java课程设计----图书馆管理系统
}
}
}
f.show();
class BookManager extends JPanel implements ActionListener{
private String [] columnNames={"图书编号","书名","定价","出版社"};
private Class []dataType={String.class,String.class,Double.class,String.class};
private CustomTableModel model=null; private JTable table=null; private Connection con=null;
private JButton btnAdd=new TextAndPicButton("image/addrow20.gif"," 增 加 ");
private JButton btnSearch=new TextAndPicButton("image/search20.gif"," 查 询 ");
private JButton btnDelete=new TextAndPicButton("image/deleterow20.gif"," 删 除 private JButton btnExit=new TextAndPicButton("image/exit20.gif"," 退 出 ");
private JFrame f=null;
public BookManager(JFrame f,Connection con){
this.f=f; this.con=con; //构建工具条
JToolBar toolBar=new JToolBar(); toolBar.add(btnAdd); toolBar.add(btnSearch); toolBar.add(btnDelete); toolBar.add(btnExit); //注册事件侦听器
btnAdd.addActionListener(this); btnSearch.addActionListener(this); btnDelete.addActionListener(this); btnExit.addActionListener(this); //构建表格
model=new CustomTableModel(0,columnNames.length,columnNames,dataType); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION ); //设定表格每列的宽度 setTableColumnWidth(0,100); setTableColumnWidth(1,200); setTableColumnWidth(2,100);
");
table = new JTable(model);
上一篇:立式齿轮油泵设计说明