?? bookmanagerbean.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 + -