简单的java图手册馆管理系统文档格式.docx
- 文档编号:22260633
- 上传时间:2023-02-03
- 格式:DOCX
- 页数:26
- 大小:44.51KB
简单的java图手册馆管理系统文档格式.docx
《简单的java图手册馆管理系统文档格式.docx》由会员分享,可在线阅读,更多相关《简单的java图手册馆管理系统文档格式.docx(26页珍藏版)》请在冰豆网上搜索。
?
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.LIGHT_GRAY);
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("
C:
\\Users\\Zpanda\\Desktop\\web\\bookStore\\images\\1.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);
this.setSize(img.getIconWidth(),img.getIconHeight());
myEvent();
this.setVisible(true);
this.setResizable(false);
privatevoidmyEvent(){
jbCancel.addActionListener(newActionListener()
publicvoidactionPerformed(ActionEvente)
{
Login.this.dispose();
}
});
jbOk.addActionListener(newActionListener()
Connectionconn=null;
Statementstm=null;
ResultSetst=null;
try
{
Class.forName();
conn=DriverManager.getConnection(,"
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.setVisible(false);
newBook("
}
else
JOptionPane.showMessageDialog(null,"
getTxtUsername().setText("
getTxtPassword().setText("
}
else
JOptionPane.showMessageDialog(null,"
?
!
getTxtUsername().setText("
getTxtPassword().setText("
}
catch(ClassNotFoundExceptione1)
e1.printStackTrace();
}catch(SQLExceptione2){
//TODOAuto-generatedcatchblock
e2.printStackTrace();
}finally{
try{
stm.close();
}catch(Exceptione3){}
//?
Connection
try{conn.close();
}catch(Exceptione4){}
}
publicstaticvoidmain(String[]args)
newLogin("
}
(2)管理界面Book.java
publicclassBookextendsJFrame{
privateJLabellblId;
privateJLabellblBname;
privateJLabellblWname;
privateJLabellblCbs;
privateJLabellblnum1;
privateJLabellblnum2;
privateJTextFieldbId;
privateJTextFieldbname;
privateJTextFieldwname;
privateJTextFieldcbs;
privateJTextFieldnum1;
privateJTextFieldnum2;
privateJButtonjbDel;
privateJTextFieldjDel;
privateJButtonjbAdd;
privateJButtonjbSearch;
privateJButtonjbUpdate;
privateJTabletable;
privateJLabeljabel;
privateJScrollPanescpDemo;
privateObjectbtnShow;
@SuppressWarnings("
unused"
)
privateObjectjth;
publicJLabelgetJabel(){
if(jabel==null)
jabel=newJLabel("
jabel.setForeground(Color.red);
jabel.setBounds(450,350,60,30);
returnjabel;
publicJButtongetJbDel(){
if(jbDel==null)
jbDel=newJButton("
jbDel.setBounds(580,400,60,30);
returnjbDel;
publicJTextFieldgetjDel(){
if(jDel==null)
jDel=newJTextField(20);
jDel.setBounds(500,350,150,30);
returnjDel;
publicJButtongetJbAdd(){
if(jbAdd==null)
jbAdd=newJButton("
jbAdd.setBounds(500,400,60,30);
returnjbAdd;
publicJButtongetJbSearch(){
if(jbSearch==null)
jbSearch=newJButton("
jbSearch.setBounds(500,450,60,30);
returnjbSearch;
publicJButtongetJbUpdate(){
if(jbUpdate==null)
jbUpdate=newJButton("
jbUpdate.setBounds(580,450,60,30);
returnjbUpdate;
serial"
publicJTablegetTable(){
JTabletable=newJTable(20,3){//?
JTable?
publicComponentprepareRenderer(TableCellRendererrenderer,introw,intcolumn){
Componentc=super.prepareRenderer(renderer,row,column);
if(cinstanceofJComponent){
((JComponent)c).setOpaque(false);
returnc;
};
table.setOpaque(false);
jtable?
this.setSize(450,400);
this.setLayout(null);
this.setLocation(270,50);
this.scpDemo=newJScrollPane();
this.scpDemo.setBounds(10,100,420,270);
this.scpDemo.setOpaque(false);
this.scpDemo.getViewport().setOpaque(false);
this.btnShow=newJButton("
(?
)"
((Component)this.btnShow).setBounds(10,50,420,30);
((AbstractButton)this.btnShow).addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventae){
btnShow_ActionPerformed(ae);
});
add(this.scpDemo);
add((Component)this.btnShow);
this.setVisible(true);
returntable;
publicvoidbtnShow_ActionPerformed(ActionEventae){
Connectionconn=null;
try{
Class.forName();
conn=DriverManager.getConnection(,"
Statementpstm=conn.createStatement();
Stringsql1="
selectcount(*)fromBook"
Stringsql2="
select*fromBook"
ResultSetrs1=pstm.executeQuery(sql1);
intcount=0;
if(rs1.next()){
count=rs1.getInt
(1);
rs1.close();
Object[][]info=newObject[count][6];
count=0;
ResultSetrs2=pstm.executeQuery(sql2);
while(rs2.next()){
info[count][0]=rs2.getString("
Bid"
info[count][1]=rs2.getString("
Bname"
info[count][2]=rs2.getString("
Wname"
info[count][3]=rs2.getString("
num1"
info[count][4]=rs2.getString("
num2"
info[count][5]=rs2.getString("
chubs"
count++;
for(Object[]o:
info){
System.out.println(o[0]);
System.out.println(o[1]);
System.out.println(o[2]);
System.out.println(o[3]);
System.out.println(o[4]);
String[]title={"
"
};
//?
JTable
this.table=newJTable(info,title);
this.jth=this.table.getTableHeader();
this.scpDemo.getViewport().add(table);
}catch(Exceptionsqle){
JOptionPane.showMessageDialog(null,"
:
+sqle.getMessage(),"
JOptionPane.ERROR_MESSAGE);
publicJLabelgetLblId(){
if(lblId==null)
lblId=newJLabel("
lblId.setForeground(Color.red);
lblId.setBounds(450,50,50,30);
returnlblId;
publicJLabelgetLblBname(){
if(lblBname==null)
lblBname=newJLabel("
lblBname.setForeground(Color.red);
lblBname.setBounds(450,100,50,30);
returnlblBname;
publicJLabelgetLblWname(){
if(lblWname==null)
lblWname=newJLabel("
lblWname.setForeground(Color.red);
lblWname.setBounds(450,150,50,30);
returnlblWname;
publicJLabelgetLblnum1(){
if(lblnum1==null)
lblnum1=newJLabel("
lblnum1.setForeground(Color.red);
lblnum1.setBounds(450,200,50,30);
returnlblnum1;
publicJLabelgetLblnum2(){
if(lblnum2==null)
lblnum2=newJLabel("
lblnum2.setForeground(Color.red);
lblnum2.setBounds(450,250,50,30);
returnlblnum2;
publicJTextFieldgetbId(){
if(bId==null)
bId=newJTextField(20);
bId.setBounds(500,50,150,30);
returnbId;
public
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 简单 java 手册 管理 系统