這篇文章給大家分享的是Java實現圖書館管理系統的方法。小編覺得挺實用的,因此分享給大家學習。如下資料是關于Java實現圖書館管理系統的代碼。
10年專注成都網站制作,成都定制網頁設計,個人網站制作服務,為大家分享網站制作知識、方案,網站設計流程、步驟,成功服務上千家企業。為您提供網站建設,網站制作,網頁設計及定制高端網站建設服務,專注于成都定制網頁設計,高端網頁制作,對成都加固等多個方面,擁有豐富的網站建設經驗。
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實現圖書館管理系統的方法介紹,詳細使用情況還得要大家自己使用過才能知道具體要領。如果想閱讀更多相關內容的文章,歡迎關注創新互聯行業資訊頻道!
新聞標題:Java實現圖書館管理系統代碼
文章鏈接:http://vcdvsql.cn/article26/jhgecg.html
成都網站建設公司_創新互聯,為您提供網站設計、服務器托管、網站收錄、網站維護、、企業建站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯