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

📄 bookmanagerbean.java

📁 JAVA图书馆管理系统 sqlserver2000 + SWING + look and feel
💻 JAVA
字号:
package com.jlib.client;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.BevelBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.TableColumnModel;

@SuppressWarnings("serial")
public class BookManagerBean extends JDialog {

	static int X = 19;
	static String[][] s1 = new String[X][7];	
	String[] s2 = {" ","书名","作者","ISBN","出版社","所在位置","状态"};
	public static JTable table;
	private JTextField textField;
	/**
	 * Launch the application
	 * @param args
	 */
	public static void main(String args[]) {
		
		try {
			UIManager.setLookAndFeel("com.nilo.plaf.nimrod.NimRODLookAndFeel");
		} catch (ClassNotFoundException e1) {
			// TODO 自动生成 catch 块
			e1.printStackTrace();
		} catch (InstantiationException e1) {
			// TODO 自动生成 catch 块
			e1.printStackTrace();
		} catch (IllegalAccessException e1) {
			// TODO 自动生成 catch 块
			e1.printStackTrace();
		} catch (UnsupportedLookAndFeelException e1) {
			// TODO 自动生成 catch 块
			e1.printStackTrace();
		}
		
		try {
			BookManagerBean dialog = new BookManagerBean();
			dialog.addWindowListener(new WindowAdapter() {
				public void windowClosing(WindowEvent e) {
					System.exit(0);
				}
			});
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog
	 */
	public BookManagerBean() {
		super();
		setTitle("书籍管理");
		getContentPane().setLayout(null);
		setBounds(100, 100, 671, 455);

		final JPanel panel = new JPanel();
		panel.setBorder(new TitledBorder(new TitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null), "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
		panel.setLayout(null);
		panel.setBounds(11, 11, 642, 397);
		getContentPane().add(panel);

		textField = new JTextField();
		textField.setText("请输入书名");
		textField.setBorder(new BevelBorder(BevelBorder.LOWERED));
		textField.setBounds(40, 10, 167, 20);
		panel.add(textField);

		final JButton button = new JButton();
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			
				com.jlib.client.BookSearchFun bsf = new com.jlib.client.BookSearchFun();
				
				bsf.send(com.jlib.client.LoginBean.PORT, com.jlib.client.LoginBean.IP, textField.getText());
				
				bsf.start();
			}
		});
		button.setText("搜索图书");
		button.setBounds(237, 8, 81, 23);
		panel.add(button);

		final JButton button_1 = new JButton();
		button_1.setText("删除图书");
		button_1.setBounds(324, 8, 81, 23);
		panel.add(button_1);

		final JButton button_2 = new JButton();
		button_2.setText("修改图书");
		button_2.setBounds(411, 8, 81, 23);
		panel.add(button_2);

		final JButton button_3 = new JButton();
		button_3.setText("刷新信息");
		button_3.setBounds(498, 8, 81, 23);
		panel.add(button_3);

		final JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 36, 622, 351);
		panel.add(scrollPane);

		table = new JTable(s1,s2);
		TableColumnModel tcm = table.getColumnModel();
		tcm.getColumn(0).setMaxWidth(20);   
        tcm.getColumn(1).setPreferredWidth(80);
        tcm.getColumn(2).setPreferredWidth(50);   
        tcm.getColumn(3).setPreferredWidth(40);
        tcm.getColumn(4).setPreferredWidth(60);   
        tcm.getColumn(5).setPreferredWidth(60);
        tcm.getColumn(6).setPreferredWidth(30);		
		table.getTableHeader().setReorderingAllowed(false); //不可整列移动
        table.getTableHeader().setResizingAllowed(true); //不可拉动表格
		scrollPane.setViewportView(table);
		//
	}

}

⌨️ 快捷键说明

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