📄 mngleechdom.java~8~
字号:
package cliniquemanager;
import javax.swing.*;
import javax.swing.table.*;
import java.util.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
/**
* <p>Title: CliniqueManager</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: shine</p>
*
* @author robin
* @version 1.0
*/
public class MngLeechdom extends JDialog {
BorderLayout borderLayout1 = new BorderLayout();
Database db;
ResultSet rs;
JButton jButton1 = new JButton("添加");
JButton jButton2 = new JButton("修改");
JButton jButton3 = new JButton("删除");
public MngLeechdom(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public MngLeechdom() {
this(new Frame(), "管理药品信息", false);
}
private void jbInit() throws Exception {
this.setLayout(borderLayout1);
this.setPreferredSize(new Dimension(800, 600));
/*表格列向量*/
Vector cell ;
/*表格行向量*/
Vector row = new Vector();
/*声明表格模型*/
DefaultTableModel tableModel = new DefaultTableModel();
/*声明表格头数组*/
String[] tableHeads = {"ID","名称", "生产商", "价格"};
/*将表格头转换过向量类型,以备表格模型使用*/
Vector tableHeadName = new Vector();
for (int i = 0; i < tableHeads.length; i++) {
tableHeadName.add(tableHeads[i]);
}
/*初始化表格数据,这些数据实例运行来源于数据库中*/
db=new Database();
rs=db.getResultSet("SELECT * FROM leechdom");
while(rs.next()){
cell = new Vector();
cell.add("" + rs.getInt("lch_id"));
cell.add(rs.getString("name"));
cell.add(rs.getString("factory"));
cell.add(""+ rs.getInt("price"));
row.add(cell);
}
/*设置表格模型*/
tableModel.setDataVector(row,tableHeadName);
/*表格使用模型*/
JTable table = new JTable(tableModel);
table.setRowHeight(20);
/*new Cursor(1)设置鼠标指针样式,12为手形*/
table.setCursor(new Cursor(12));
/*
table.setSelectionBackground(Color.black);
table.setSelectionForeground(Color.white);
table.setGridColor(Color.black);
makeFace(table);
table.setBackground(new Color(206,120,50));
table.setCellSelectionEnabled(false);
*/
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setCursor(new Cursor(12));
this.add(scrollPane, java.awt.BorderLayout.CENTER);
//添加按钮
JPanel pnlButton=new JPanel();
pnlButton.setLayout(new FlowLayout());
pnlButton.add(jButton1);
pnlButton.add(jButton2);
pnlButton.add(jButton3);
this.add(pnlButton,BorderLayout.SOUTH);
// this.add(new Button(),BorderLayout.NORTH);
//this.add(new Button(),BorderLayout.EAST);
// this.add(new Button(),BorderLayout.WEST);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -