资源描述:
《java编写的简单图书管理系统》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Java编写的简单图书管理系统主界面代码实现packageLibrary;importjava.awt.BorderLayout;importjava.awt.Color;importjava.awt.Container;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava
2、.sql.SQLException;importjava.sql.Statement;importjavax.swing.ImageIcon;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JPasswordField;importjavax.swing.JTextField;public
3、classLoginextendsJFrame{privatestaticfinallongserialVersionUID=1L;privateJLabeljlUsername;privateJLabeljlPwd;privateJTextFieldtxtUsername;//用户名privateJTextFieldtxtPassword;//密码privateJButtonjbOk;privateJButtonjbCancel;publicJLabelgetJlUsername(){if(jlUsername==null){jlU
4、sername=newJLabel("账号");jlUsername.setForeground(Color.BLACK);jlUsername.setBounds(118,40,85,30);}returnjlUsername;}publicJLabelgetJlPwd(){if(jlPwd==null){jlPwd=newJLabel("密码");jlPwd.setForeground(Color.BLACK);jlPwd.setBounds(118,100,85,30);}returnjlPwd;}publicJTextFiel
5、dgetTxtUsername(){if(txtUsername==null){txtUsername=newJTextField(20);txtUsername.setBounds(180,40,200,30);}returntxtUsername;}publicJTextFieldgetTxtPassword(){if(txtPassword==null){txtPassword=newJPasswordField(20);txtPassword.setBounds(180,100,200,30);}returntxtPasswo
6、rd;}publicJButtongetJbOk(){if(jbOk==null){jbOk=newJButton("登陆");jbOk.setBounds(150,180,90,30);//jbOk.addActionListener(this);}returnjbOk;}publicJButtongetJbCancel(){if(jbCancel==null){jbCancel=newJButton("取消");jbCancel.setBounds(300,180,90,30);}returnjbCancel;}publicLog
7、in(Stringtitle){super(title);//JFrameframe=newJFrame();Containercantainer=this.getContentPane();this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);ImageIconimg=newImageIcon("F:\Java\传习\src\Library\ZF`XY`H48I_}U)C4~}M2~C4.jpg");//这是背景图片JLabelimgLabel=newJLabel(img)
8、;//将背景图放在标签里。this.getLayeredPane().add(imgLabel,newInteger(Integer.MIN_VALUE));//注意这里是关键,将背景标签添加到jfram的Layered