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.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;publicclassLoginextendsJFrame{privatestaticfinallongserialVersionUID=1L;privateJLabeljlUsername;privateJLabeljlPwd;privateJTextFieldtxtUsername;//用户名privateJTextFieldtxtPassword;//密码privateJButtonjbOk;privateJButtonjbCancel;publicJLabelgetJlUsername(){if(jlUsername==null){jlUsername=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;}publicJTextFieldgetTxtUsername(){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);}returntxtPassword;}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;}publicLogin(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);//将背景图放在标签里。this.getLayeredPane().add(imgLabel,newInteger(Integer.MIN_VALUE));//注意这里是关键,将背景标签添加到jfram的LayeredPane面板里。imgLabel.setBounds(0,0,img.getIconWidth(),img.getIconHeight());//设置背景标签的位置cantainer.setLayout(newBorderLayout());imgLabel.setLayout(null);imgLabel.add(getJlUsername());imgLabel.add(getTxtUsername());imgLabel.add(getJlPwd());imgLabel.add(getTxtPassword());imgLabel.add(getJbOk());imgLabel.add(getJbCancel());cantainer.add(imgLabel,BorderLayout.NORTH);((JPanel)cantainer).setOpaque(false);//注意这里,将内容面板设为透明。这样LayeredPane面板中的背景才能显示出来。this.setSize(img.getIconWidth(),img.getIconHeight());myEvent();this.setVisible(true);this.setResizable(true);}privatevoidmyEvent(){jbCancel.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){Login.this.dispose();}});jbOk.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){Connectionconn=null;Statementstm=null;ResultSetst=null;try{Class.forName("com.mysql.jdbc.Driver");conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/library","sa","123456");stm=conn.createStatement();Stringsql="select*fromuser";//Stringsql1="selectpswfromuser";st=stm.executeQuery(sql);//st1=stm.executeQuery(sql1);if(st.next()){if(txtUsername.getText().equals(st.getString("id"))txtPassword.getText().equals(st.getString("psw"))){Login.this.setV...