Java小項目之:圖書館管理系統!有借有還,再借不難

Java小項目之:有借有還,再借不難!圖書館管理系統

今天給大家分享的java小項目是圖書館管理系統。

這個圖書館管理系統是很完善的,包括書籍信息錄入、借閱者信息、書籍類別添加、新書訂購等等功能。和現實生活中的圖書館管理系統沒什麼兩樣,毫不誇張的說,你只要學會了今天我分享的這個小項目,以後自己創建一個圖書館管理系統是沒一點問題的。

按照慣例先上圖:

Java小項目之:圖書館管理系統!有借有還,再借不難

部分代碼展示:

Java小項目之:圖書館管理系統!有借有還,再借不難

Java小項目之:圖書館管理系統!有借有還,再借不難

public class BookLoginIFrame extends JFrame {
private class BookResetAction implements ActionListener {
public void actionPerformed(final ActionEvent e){
username.setText("");
 
password.setText("");
}
}
class BookLoginAction implements ActionListener {
public void actionPerformed(final ActionEvent e) {
user = Dao.check(username.getText(), password.getText());
if (user.getName() != null) {
try {
Library frame = new Library();
frame.setVisible(true);
BookLoginIFrame.this.setVisible(false);
} catch (Exception ex) {
ex.printStackTrace(); 
}
} else {
JOptionPane.showMessageDialog(null, "只有管理員才可以登錄!");
username.setText("");
password.setText("");
}
}
}
private JPasswordField password;
private JTextField username;
private JButton login;
private JButton reset;
private static Operater user;
/**
* Launch the application
* @param args
*/
/**
* Create the frame
*/
public BookLoginIFrame() {
super();
final BorderLayout borderLayout = new BorderLayout();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
borderLayout.setVgap(10); 
getContentPane().setLayout(borderLayout);
setTitle("圖書館管理系統登錄");
setBounds(100, 100, 285, 194);
final JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.setBorder(new EmptyBorder(0, 0, 0, 0));
getContentPane().add(panel);
final JPanel panel_2 = new JPanel();
final GridLayout gridLayout = new GridLayout(0, 2);
gridLayout.setHgap(5);
gridLayout.setVgap(20);
panel_2.setLayout(gridLayout);
panel.add(panel_2);
final JLabel label = new JLabel();
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setPreferredSize(new Dimension(0, 0));
label.setMinimumSize(new Dimension(0, 0));
panel_2.add(label);
label.setText("用 戶 名:");
username = new JTextField(20);
username.setPreferredSize(new Dimension(0, 0));
panel_2.add(username);
final JLabel label_1 = new JLabel();
label_1.setHorizontalAlignment(SwingConstants.CENTER);
panel_2.add(label_1); 
label_1.setText("密 碼:");
password = new JPasswordField(20);
password.setDocument(new MyDocument(6));
password.setEchoChar('*');//設置密碼框的回顯字符
password.addKeyListener(new KeyAdapter() {
public void keyPressed(final KeyEvent e) {
if (e.getKeyCode() == 10)
login.doClick();
}
});
panel_2.add(password);
final JPanel panel_1 = new JPanel(); 
panel.add(panel_1, BorderLayout.SOUTH);
login=new JButton();
login.addActionListener(new BookLoginAction());
login.setText("登錄");
panel_1.add(login);
reset=new JButton();
reset.addActionListener(new BookResetAction());
reset.setText("重置");
panel_1.add(reset);
final JLabel tupianLabel = new JLabel();
ImageIcon loginIcon=CreatecdIcon.add("login.jpg");
tupianLabel.setIcon(loginIcon);
 
tupianLabel.setOpaque(true);
tupianLabel.setBackground(Color.GREEN);
tupianLabel.setPreferredSize(new Dimension(260, 60));
panel.add(tupianLabel, BorderLayout.NORTH);
//
setVisible(true);
setResizable(false);
//setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
public static Operater getUser() {
return user;
}
public static void setUser(Operater user) { 
BookLoginIFrame.user = user;
}
}

需要這個圖書館管理系統素材和源碼的小夥伴可以私信我領取,當然我不止有這點資料!

Java小項目之:圖書館管理系統!有借有還,再借不難

喜歡這樣文章的可以關注我,我會持續更新,你們的關注是我更新的動力!

祝關注我的人都:身體健康,財源廣進,福如東海,壽比南山,早生貴子,從不掉髮!


分享到:


相關文章: