最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Java swing圖書管理系統(tǒng)2(個(gè)人設(shè)計(jì)思考得出的全功能簡(jiǎn)易原版)

2020-04-19 21:41 作者:詩(shī)書畫唱  | 我要投稿



package denglu;


import java.awt.Color;

import java.awt.Font;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.Vector;


import javax.swing.BorderFactory;

import javax.swing.ButtonGroup;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JRadioButton;

import javax.swing.JScrollPane;

import javax.swing.JTable;

import javax.swing.JTextField;

import javax.swing.JTree;

import javax.swing.UIManager;

import javax.swing.event.TreeSelectionEvent;

import javax.swing.event.TreeSelectionListener;

import javax.swing.table.DefaultTableModel;

import javax.swing.tree.DefaultMutableTreeNode;


import Model.DBUlits;


public class dengLuHouJieMian extends JFrame {


public static JButton btn_xiugai, btn_quxiao = null;


public static DefaultTableModel dtm = null;

static JButton JButton1, JButton2, JButton3, JButton4 = null;

static JLabel JLabel1, JLabel2, JLabel3, JLabel4, lb_title, lb_uname,

lb_pwd, lb_name, lb_sex, lb_phone = null;

static JPanel JPanel_mianBan_top, JPanel_mianBan_left_bottom,

JPanel_mianBan_qieHuanYongHu, JPanel_mianBan_JYPHB,

JPanel_mianBan_GRXXXG, JPanel_mianBan_TCXT = null;

static JRadioButton rb1, rb2 = null;

public static JTable tb1 = null;

static JTextField txt_uname, txt_pwd, txt_name, txt_phone = null;

// public static yonghu user_xinxi;

JTree JTree1 = null;// 聲明一個(gè)樹控件


public dengLuHouJieMian(String str) {


this.setTitle("管理員用戶登錄后的主界面");


this.setLayout(null);


this.setSize(700, 700);


this.setLocationRelativeTo(null);


JPanel_mianBan_top = new JPanel(null);


JButton1 = new JButton("切換用戶", new ImageIcon("img//a.jpg"));


JButton1.setVerticalTextPosition(JButton.BOTTOM);

// TOP

JButton1.setHorizontalTextPosition(JButton.CENTER);


JButton1.setBounds(100, 0, 120, 130);


JButton2 = new JButton("借閱排行榜", new ImageIcon("img//b.jpg"));


JButton2.setVerticalTextPosition(JButton.BOTTOM);


JButton2.setHorizontalTextPosition(JButton.CENTER);


JButton2.setBounds(250, 0, 120, 130);


JButton3 = new JButton("個(gè)人信息管理", new ImageIcon("img//c.jpg"));


JButton3.setVerticalTextPosition(JButton.BOTTOM);


JButton3.setHorizontalTextPosition(JButton.CENTER);


JButton3.setBounds(400, 0, 120, 130);


JButton4 = new JButton("退出系統(tǒng)", new ImageIcon("img//d.jpg"));


JButton4.setVerticalTextPosition(JButton.BOTTOM);


JButton4.setHorizontalTextPosition(JButton.CENTER);


JButton4.setBounds(550, 0, 120, 130);


JPanel_mianBan_top.add(JButton1);


JPanel_mianBan_top.add(JButton2);


JPanel_mianBan_top.add(JButton3);


JPanel_mianBan_top.add(JButton4);


JPanel_mianBan_left_bottom = new JPanel(null);


JPanel_mianBan_qieHuanYongHu = new JPanel(null);


JPanel_mianBan_JYPHB = new JPanel(null);


JPanel_mianBan_GRXXXG = new JPanel(null);


JPanel_mianBan_TCXT = new JPanel(null);


/* 給所有的JTree控件設(shè)置統(tǒng)一的圖標(biāo), 所以一定要在實(shí)例化JTree之前使用,否則沒有效果 */


UIManager.put("Tree.collapsedIcon", new ImageIcon("img//1.png"));// 默認(rèn)打開圖標(biāo)


UIManager.put("Tree.expandedIcon", new ImageIcon("img//2.png"));// 打開后圖標(biāo)


UIManager.put("Tree.openIcon", new ImageIcon("img//3.png"));// 打開


UIManager.put("Tree.closedIcon", new ImageIcon("img//4.png"));// 關(guān)閉


UIManager.put("Tree.leafIcon", new ImageIcon("img//5.png"));// 打開后小圖標(biāo)


DefaultMutableTreeNode dmtn1 = new DefaultMutableTreeNode("菜單列表");


DefaultMutableTreeNode dmtn_yonghu = new DefaultMutableTreeNode("用戶管理");


// Default(默認(rèn)值)mutable(易變的)Tree(樹)node(節(jié)點(diǎn))

DefaultMutableTreeNode dmtn_tuShu = new DefaultMutableTreeNode("圖書管理");

DefaultMutableTreeNode dmtn_tuShuLeiXing = new DefaultMutableTreeNode(

"圖書類型管理");


DefaultMutableTreeNode dmtn_jieyue = new DefaultMutableTreeNode("借閱管理");

dmtn1.add(dmtn_yonghu);

dmtn1.add(dmtn_tuShu);

dmtn1.add(dmtn_tuShuLeiXing);

dmtn1.add(dmtn_jieyue);

JTree1 = new JTree(dmtn1);


JTree1.addTreeSelectionListener(new glsj(this));


JTree1.setBounds(10, 10, 150, 300);


JPanel_mianBan_left_bottom.add(JTree1);


JLabel1 = new JLabel();


JLabel2 = new JLabel();


JLabel3 = new JLabel();


JLabel4 = new JLabel();


JLabel1.setBounds(0, 0, 534, 564);


/* setBounds(x,y,size_x,size_y) */


JLabel2.setBounds(0, 0, 534, 564);


JLabel3.setBounds(0, 0, 534, 564);


JLabel4.setBounds(0, 0, 534, 564);


// JLabel1.setIcon(new ImageIcon("img//11.png"));


// JLabel2.setIcon(new ImageIcon("img//22.png"));

//

// JLabel3.setIcon(new ImageIcon("img//33.png"));

//

// JLabel4.setIcon(new ImageIcon("img//44.png"));


JPanel_mianBan_qieHuanYongHu.add(JLabel1);


JPanel_mianBan_JYPHB.add(JLabel2);


JPanel_mianBan_GRXXXG.add(JLabel3);


JPanel_mianBan_TCXT.add(JLabel4);


JButton1.addActionListener(new glsj(this));


JButton2.addActionListener(new glsj(this));


JButton3.addActionListener(new glsj(this));


JButton4.addActionListener(new glsj(this));


JPanel_mianBan_top.setBounds(0, 0, 700, 130);


JPanel_mianBan_left_bottom.setBounds(0, 130, 150, 600);

/*

* 執(zhí)行順序要注意,若"個(gè)人信息修改"下面的內(nèi)容寫在JPanel_mianBan_left_bottom.setBounds(0, 130,

* 150, 600); 上面上面就會(huì)主(默認(rèn))界面就會(huì)有,反之只有JPanel_mianBan_left_bottom有,

* 可以用注釋或打印,彈出語句來判斷是否有錯(cuò),錯(cuò)在哪里

*/

lb_title = new JLabel("個(gè)人信息修改");

lb_title.setFont(new Font("微軟雅黑", Font.BOLD, 30));

lb_title.setBounds(120, 40, 200, 30);


// JPanel_mianBan_GRXXXG.add(lb_title);

lb_uname = new JLabel("用戶名:");

lb_pwd = new JLabel("密碼:");

lb_name = new JLabel("真實(shí)姓名:");

lb_sex = new JLabel("性別:");

lb_phone = new JLabel("電話:");

lb_uname.setBounds(100, 90, 80, 30);

lb_pwd.setBounds(100, 130, 80, 30);

lb_name.setBounds(100, 170, 80, 30);

lb_sex.setBounds(100, 210, 80, 30);

lb_phone.setBounds(100, 250, 80, 30);

JPanel_mianBan_GRXXXG.add(lb_uname);

JPanel_mianBan_GRXXXG.add(lb_pwd);

JPanel_mianBan_GRXXXG.add(lb_name);

JPanel_mianBan_GRXXXG.add(lb_sex);

JPanel_mianBan_GRXXXG.add(lb_phone);

JPanel_mianBan_GRXXXG.add(lb_title);

txt_pwd = new JTextField();

txt_name = new JTextField();

txt_phone = new JTextField();

txt_uname = new JTextField();

txt_uname.setEditable(false);


btn_xiugai = new JButton("修改");

btn_xiugai.addActionListener(new glsj(this));


btn_quxiao = new JButton("取消");

btn_xiugai.setBounds(120, 290, 70, 30);

btn_quxiao.setBounds(240, 290, 70, 30);

txt_uname.setBounds(180, 90, 120, 30);

txt_pwd.setBounds(180, 130, 120, 30);

txt_name.setBounds(180, 170, 120, 30);

txt_phone.setBounds(180, 250, 120, 30);

rb1 = new JRadioButton("男", true);

rb2 = new JRadioButton("女", false);


ButtonGroup bg = new ButtonGroup();

bg.add(rb1);

bg.add(rb2);

rb1.setBounds(180, 210, 60, 30);

rb2.setBounds(250, 210, 60, 30);

JPanel_mianBan_GRXXXG.add(txt_uname);

JPanel_mianBan_GRXXXG.add(txt_pwd);

JPanel_mianBan_GRXXXG.add(txt_name);

JPanel_mianBan_GRXXXG.add(rb1);

JPanel_mianBan_GRXXXG.add(rb2);

JPanel_mianBan_GRXXXG.add(txt_phone);


JPanel_mianBan_GRXXXG.add(btn_quxiao);

JPanel_mianBan_GRXXXG.add(btn_xiugai);


JPanel_mianBan_qieHuanYongHu.setBounds(150, 130, 550, 600);


// JPanel_mianBan_JYPHB.setBounds(150, 130, 550, 600);


JPanel_mianBan_GRXXXG.setBounds(150, 130, 550, 600);


JPanel_mianBan_TCXT.setBounds(150, 130, 550, 600);


JPanel_mianBan_top.setBorder(BorderFactory.createLineBorder(Color.red));


JPanel_mianBan_left_bottom.setBorder(BorderFactory

.createLineBorder(Color.green));


JPanel_mianBan_qieHuanYongHu.setBorder(BorderFactory

.createLineBorder(Color.blue));


JPanel_mianBan_JYPHB.setBorder(BorderFactory

.createLineBorder(Color.red));


JPanel_mianBan_GRXXXG.setBorder(BorderFactory

.createLineBorder(Color.green));


JPanel_mianBan_TCXT.setBorder(BorderFactory

.createLineBorder(Color.blue));

if (JPanel_mianBan_JYPHB != null) {

this.remove(JPanel_mianBan_JYPHB);

}

Vector<Object> v_head = new Vector<Object>();

v_head.add("名次");

v_head.add("圖書名稱");

v_head.add("借閱數(shù)量");

String sql = "select * from jieyue a inner join tushu b on a.ts_id=b.ts_id order by a.jnum desc";

Vector<Vector<Object>> v_body = new Vector<Vector<Object>>();

ResultSet res = DBUlits.select(sql);

int num = 1;

try {

while (res.next()) {

Vector<Object> v = new Vector<Object>();

v.add(num++);

v.add(res.getString("ts_name"));

v.add(res.getInt("jnum"));

v_body.add(v);

}

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

dtm = new DefaultTableModel(v_body, v_head);

// 顯示表格標(biāo)題和內(nèi)容,再isCellEditable上面,isCellEditable才有效

dtm = new DefaultTableModel(v_body, v_head) {

@Override

public boolean isCellEditable(int a, int b) {

return false;

}

};


tb1 = new JTable(dtm);

// tb1.addMouseListener(new shijian_zc(this));

// dtm = new DefaultTableModel(v_body, v_head);

// tb1 = new JTable(dtm);

JScrollPane jsp = new JScrollPane(tb1);

jsp.setBounds(0, 0, 500, 500);

JPanel_mianBan_JYPHB = new JPanel();

JPanel_mianBan_JYPHB.add(jsp);

JPanel_mianBan_JYPHB.setBorder(BorderFactory

.createLineBorder(Color.green));

// jp5.add(new JLabel("ssssssssssssssssssssssssss"));

JPanel_mianBan_JYPHB.setBounds(150, 130, 550, 600);


// // tb1.addMouseListener(new shijian_zc(this));

this.add(JPanel_mianBan_JYPHB);

this.add(JPanel_mianBan_top);


this.add(JPanel_mianBan_left_bottom);


this.add(JPanel_mianBan_qieHuanYongHu);


this.add(JPanel_mianBan_JYPHB);


this.add(JPanel_mianBan_GRXXXG);


this.add(JPanel_mianBan_TCXT);

// txt_uname.setText(denglu.user_xinxi.getYh_uname());

// txt_pwd.setText(denglu.user_xinxi.getYh_pwd());

// txt_phone.setText(denglu.user_xinxi.getYh_phone());

// txt_name.setText(denglu.user_xinxi.getYh_name());

// String sql = "select * from yonghu where yh_uname='" + 1 + "'";

// String sql = "select * from yonghu where yh_uname='"

// + denglu.user_xinxi + "'";

String sql1 = "select * from yonghu where yh_uname='" + str + "'";


ResultSet res1 = DBUtils.Select(sql1);


try {

while (res1.next()) {

// JOptionPane.showMessageDialog(null,

// "res.next()查到內(nèi)容了");

txt_uname.setText(res1.getString("yh_uname"));

txt_pwd.setText(res1.getString("yh_pwd"));

txt_phone.setText(res1.getString("yh_phone"));

txt_name.setText(res1.getString("yh_name"));

String sex = res1.getString("yh_sex");

if (sex.equals("男")) {

rb1.setSelected(true);

rb2.setSelected(false);

} else if (sex.equals("女")) {

rb2.setSelected(true);

rb1.setSelected(false);

}


}

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);


}


}


class glsj implements ActionListener, TreeSelectionListener, MouseListener {


public dengLuHouJieMian dd = null;


public glsj(dengLuHouJieMian dengLuHouJieMian) {


dd = dengLuHouJieMian;


}


@Override

public void actionPerformed(ActionEvent arg0) {


String str = arg0.getActionCommand();

// if(str . equals("切換用戶")){

// //切換用戶,就實(shí)例化登錄窗體,將當(dāng)前窗體隱藏掉即可

// new deng1u();

// //ss. setvisible(true);

// zz. setVisible(false);

// }else. if(str . equals("借閱排行榜" )){

// zz.jp5. setVisible(true);

// zz. jieyue load();

// zz. jp3. setvisible(false);

// zz. jp4. setVisible(false);

// zz .jp6.setVisible(false);

// zz.jp7.setVisible(false);

// }else if(str . equals("個(gè)人信息管理")){


if (arg0.getSource() == dd.JButton1) {

/* qieHuanYongHu:切換用戶,JYPHB:JieYuePaiHanBang,借閱排行榜 */

new denglu();


} else if (str.equals("借閱排行榜")) {


dd.JPanel_mianBan_JYPHB.setVisible(true);

// 讓JPanel_mianBan_JYPHB的區(qū)域顯示,其他的區(qū)域隱藏


dd.JPanel_mianBan_qieHuanYongHu.setVisible(false);


dd.JPanel_mianBan_GRXXXG.setVisible(false);


dd.JPanel_mianBan_TCXT.setVisible(false);


} else if (arg0.getSource() == dd.JButton3) {


dd.JPanel_mianBan_GRXXXG.setVisible(true);

// 讓JPanel_mianBan_GRXXXG的區(qū)域顯示,其他的區(qū)域隱藏


dd.JPanel_mianBan_JYPHB.setVisible(false);


dd.JPanel_mianBan_qieHuanYongHu.setVisible(false);


dd.JPanel_mianBan_TCXT.setVisible(false);


} else if (arg0.getSource() == dd.JButton4) {

System.exit(0);


// dd.JPanel_mianBan_TCXT.setVisible(true);

// // 讓JPanel_mianBan_TCXT的區(qū)域顯示,其他的區(qū)域隱藏

//

// dd.JPanel_mianBan_JYPHB.setVisible(false);

//

// dd.JPanel_mianBan_GRXXXG.setVisible(false);

//

// dd.JPanel_mianBan_qieHuanYongHu.setVisible(false);


} else if (arg0.getActionCommand().equals("修改")) {

// 得到用戶的信息

String uname = dd.txt_uname.getText();

String phone = dd.txt_phone.getText();

String name = dd.txt_name.getText();

String pwd = dd.txt_pwd.getText();

String sex = "男";

if (dd.rb2.isSelected()) {

sex = "女";

}


String sql = "update yonghu set yh_pwd='" + pwd + "', yh_name='"

+ name + "' , yh_phone= ' " + phone + "' , yh_sex='" + sex

+ "' where yh_uname='" + uname + "'";

if (DBUtils.ZSG(sql)) {

JOptionPane.showMessageDialog(null, "個(gè)人信息更新成功");

return;

} else {

JOptionPane.showMessageDialog(null, "出現(xiàn)了未知的錯(cuò)誤,請(qǐng)重試");

}


}


}


// 點(diǎn)擊Tree中的子節(jié)點(diǎn)會(huì)執(zhí)行的方法


@Override

public void mouseClicked(MouseEvent arg0) {

// TODO Auto-generated method stub


}


@Override

public void mouseEntered(MouseEvent arg0) {

// TODO Auto-generated method stub


}


@Override

public void mouseExited(MouseEvent arg0) {

// TODO Auto-generated method stub


}


@Override

public void mousePressed(MouseEvent arg0) {

// TODO Auto-generated method stub


}


@Override

public void mouseReleased(MouseEvent arg0) {

// TODO Auto-generated method stub


}


@Override

public void valueChanged(TreeSelectionEvent arg0) {


// TODO Auto-generated method stub


// 獲取最后一次點(diǎn)擊的那個(gè)節(jié)點(diǎn)


DefaultMutableTreeNode str = (DefaultMutableTreeNode) dd.JTree1


.getLastSelectedPathComponent();


// JOptionPane.showMessageDialog(null, str.toString());


if (str.toString().equals("用戶管理")) {


new yonghuguanli();


} else if (str.toString().equals("圖書管理")) {


new tuShuGuanLi();

// dd.setVisible(false);


} else if (str.toString().equals("圖書類型管理")) {


new tuShuLeiXingGuanLi();


} else if (str.toString().equals("借閱管理")) {


new jieyue();


}

}


}


package denglu;


public class gongjvClass {

public static String uname = " ";

}




Java swing圖書管理系統(tǒng)2(個(gè)人設(shè)計(jì)思考得出的全功能簡(jiǎn)易原版)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
武宁县| 登封市| 延津县| 前郭尔| 西和县| 南召县| 英德市| 遂平县| 黄平县| 美姑县| 平定县| 田东县| 岳池县| 云龙县| 弥渡县| 大理市| 宣城市| 建始县| 潼南县| 枣强县| 洪雅县| 辽宁省| 乐山市| 裕民县| 湖南省| 法库县| 彭阳县| 慈利县| 巴塘县| 颍上县| 界首市| 崇礼县| 乐昌市| 莒南县| 乌苏市| 奉贤区| 台湾省| 阿坝县| 甘孜县| 株洲县| 广安市|