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

📄 contract.java

📁 java语言编写的基于sql2000开发的图书馆管理系统
💻 JAVA
字号:
package purchase;

import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JButton;
import javax.swing.table.DefaultTableModel;

import main.DataBase;

import java.awt.Font;

class Contract extends JPanel {

	private static final long serialVersionUID = 1L;
	private JLabel jLabel = null;
	private JScrollPane jScrollPane = null;
	private JButton register = null;
	private static JTable jTable = null;
	private static DefaultTableModel modelForTable;
	/**
	 * This is the default constructor
	 */
	public Contract() {
		super();
		initialize();
		Contract.setModelForTable();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		jLabel = new JLabel();
		jLabel.setBounds(new Rectangle(4, 5, 60, 18));
		jLabel.setText("查看合同");
		this.setSize(500, 280);
		this.setLayout(null);
		this.add(jLabel, null);
		this.add(getJScrollPane(), null);
		this.add(getRegister(), null);
	}

	/**
	 * This method initializes jScrollPane	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJScrollPane() {
		if (jScrollPane == null) {
			jScrollPane = new JScrollPane();
			jScrollPane.setBounds(new Rectangle(17, 34, 466, 188));
			jScrollPane.setViewportView(getJTable());
		}
		return jScrollPane;
	}

	/**
	 * This method initializes register	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getRegister() {
		if (register == null) {
			register = new JButton();
			register.setBounds(new Rectangle(44, 229, 118, 37));
			register.setFont(new Font("\u6977\u4f53_GB2312", Font.BOLD, 18));
			register.setText("到货登记");
			register.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					int i=Contract.getJTable().getSelectedRow();
					if(i<0){
						javax.swing.JOptionPane.showMessageDialog(null,"图书馆管理系统\n"+
						"请选择一条记录 \n");
					}else{
						String contractNum=(String)Contract.modelForTable.getValueAt(i,0);
						new GoodsRegister(contractNum);
						
					}
				}
			});
		}
		return register;
	}

	/**
	 * This method initializes jTable	
	 * 	
	 * @return javax.swing.JTable	
	 */
	private static JTable getJTable() {
		if (jTable == null) {
			jTable = new JTable();
		}
		return jTable;
	}
	public static void setModelForTable(){
		String sql="select contract_num,book_store,book_name,quantity,book_value,"+
					"should_deal_time,real_deal_time from contract";
		String[] englishColumns = { "contract_num", "book_store", "book_name",
				"quantity" ,"book_value","should_deal_time","real_deal_time"};
		String[] chineseColumns = { "合同号", "书商", "书名", "数量","交易额",
				"计划交易时间","实际交易时间" };
		DefaultTableModel modelForTable = DataBase.createModelForTable(
				englishColumns, chineseColumns, sql);
		Contract.modelForTable=modelForTable;
		Contract.getJTable().setModel(modelForTable);
		Contract.getJTable().repaint();
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"

⌨️ 快捷键说明

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