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

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

Java Swing解析版:圖書管理系統(tǒng)(2)實(shí)戰(zhàn)項(xiàng)目開發(fā)

2020-04-06 19:53 作者:詩書畫唱  | 我要投稿




package swingPackage;


import java.awt.Color;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;


import javax.swing.BorderFactory;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JTree;

import javax.swing.UIManager;

import javax.swing.event.TreeSelectionEvent;

import javax.swing.event.TreeSelectionListener;

import javax.swing.tree.DefaultMutableTreeNode;

//extends

//

//延伸


public class ChengGongDengLuHouDejiemian extends JFrame {

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

static JLabel JLabel1, JLabel2, JLabel3, JLabel4 = null;

static JPanel JPanel1, JPanel2, JPanel3, JPanel4, JPanel5, JPanel6 = null;

JTree JTree1 = null;/* 聲明一個(gè)樹控件,JTree為樹形控件,即像樹一樣的按鈕等的控件等 */


public ChengGongDengLuHouDejiemian() {


this.setTitle("登錄后的主界面");

/* layout:布局 */

/* setLayout()設(shè)置用戶界面上的屏幕組件的格式布局,是java圖形界面編程的常用方法。默認(rèn)為流式布局。 */

this.setLayout(null);

this.setSize(700, 700);

/*

* location:地點(diǎn).relative:親屬。 public void setLocationRelativeTo(Component

* c)設(shè)置窗口相對于指定組件的位置。 如果組件當(dāng)前未顯示,或者 c 為 null,則此窗口將置于屏幕的中央。

*/

this.setLocationRelativeTo(null);

/* JPanel:面板 */

JPanel1 = new JPanel(null);

/* image:形象。icon:圖標(biāo) */

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

/*

* vertical:垂直的。position:位置。

* JButton1.setVerticalTextPosition(JButton.TOP)定義標(biāo)簽中垂直方向的文字以頂端對齊

*/

JButton1.setVerticalTextPosition(JButton.TOP);

/* horizontal:水平的 */

JButton1.setHorizontalTextPosition(JButton.CENTER);

/* bounds:范圍 */

JButton1.setBounds(100, 20, 100, 60);

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

JButton2.setVerticalTextPosition(JButton.TOP);


JButton2.setHorizontalTextPosition(JButton.CENTER);

JButton2.setBounds(250, 20, 100, 60);

JButton3 = new JButton("系統(tǒng)管理", new ImageIcon("img//3.png"));

JButton3.setVerticalTextPosition(JButton.TOP);


JButton3.setHorizontalTextPosition(JButton.CENTER);

JButton3.setBounds(400, 20, 100, 60);

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

JButton4.setVerticalTextPosition(JButton.TOP);


JButton4.setHorizontalTextPosition(JButton.CENTER);

JButton4.setBounds(550, 20, 100, 60);


JPanel1.add(JButton1);

JPanel1.add(JButton2);

JPanel1.add(JButton3);

JPanel1.add(JButton4);


JPanel2 = new JPanel(null);

JPanel3 = new JPanel(null);

JPanel4 = new JPanel(null);

JPanel5 = new JPanel(null);

JPanel6 = new JPanel(null);


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


/*

* collapsed:倒塌。expanded:被擴(kuò)大的。open:開著的。

* closed是形容詞“關(guān)閉的”,也是close的過去式和過去分詞。 leaf:葉子

*/


/*

* 用戶界面(User Interface,簡稱UI,亦稱使用者界面)是指對軟件的人機(jī)交互、操作邏輯、界面美觀的整體設(shè)計(jì),

* 是系統(tǒng)和用戶之間進(jìn)行交互和信息交換的介質(zhì)。Manager(經(jīng)理;管理委員;主教練;經(jīng)紀(jì)人;總管;)管理程序

* put,(英文單詞,動(dòng)詞,翻譯為)放置(,寫,實(shí)施,使(人或物)處于(某種狀態(tài))等,在句中可作謂語。)

*/

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)

/* Default:(不履行; 違約; 拖欠; 未到庭;) 默認(rèn)值 */

/* Mutable易變的;很可能改變的;反復(fù)無常的;用情不專的 */


/*

* DefaultMutableTreeNode:節(jié)點(diǎn)。 new DefaultMutableTreeNode:新節(jié)點(diǎn)

*/

/* node:節(jié)點(diǎn) */

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

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

DefaultMutableTreeNode dmtn_yonghu_insert = new DefaultMutableTreeNode(

"增加用戶");

DefaultMutableTreeNode dmtn_yonghu_update = new DefaultMutableTreeNode(

"修改用戶");

DefaultMutableTreeNode dmtn_yonghu_delete = new DefaultMutableTreeNode(

"刪除用戶");

DefaultMutableTreeNode dmtn_yonghu_select = new DefaultMutableTreeNode(

"查詢用戶");

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

DefaultMutableTreeNode dmtn_jieyue_insert = new DefaultMutableTreeNode(

"增加借閱信息");

DefaultMutableTreeNode dmtn_jieyue_update = new DefaultMutableTreeNode(

"修改借閱信息");

DefaultMutableTreeNode dmtn_jieyue_delete = new DefaultMutableTreeNode(

"刪除借閱信息");

DefaultMutableTreeNode dmtn_jieyue_select = new DefaultMutableTreeNode(

"查詢借閱信息");

// 從小到大的方向進(jìn)行添加呢內(nèi)容

dmtn_yonghu.add(dmtn_yonghu_insert);

dmtn_yonghu.add(dmtn_yonghu_update);

dmtn_yonghu.add(dmtn_yonghu_delete);

dmtn_yonghu.add(dmtn_yonghu_select);

dmtn_jieyue.add(dmtn_jieyue_insert);

dmtn_jieyue.add(dmtn_jieyue_update);

dmtn_jieyue.add(dmtn_jieyue_delete);

dmtn_jieyue.add(dmtn_jieyue_select);

dmtn1.add(dmtn_yonghu);

dmtn1.add(dmtn_jieyue);


JTree1 = new JTree(dmtn1);


JTree1.addTreeSelectionListener(new shijian_zc(this));

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

JPanel2.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"));

JPanel3.add(JLabel1);

JPanel4.add(JLabel2);

JPanel5.add(JLabel3);

JPanel6.add(JLabel4);

JButton1.addActionListener(new shijian_zc(this));

JButton2.addActionListener(new shijian_zc(this));

JButton3.addActionListener(new shijian_zc(this));

JButton4.addActionListener(new shijian_zc(this));

JPanel1.setBounds(0, 0, 700, 100);

JPanel2.setBounds(0, 100, 150, 600);

JPanel3.setBounds(150, 100, 550, 600);

JPanel4.setBounds(150, 100, 550, 600);

JPanel5.setBounds(150, 100, 550, 600);

JPanel6.setBounds(150, 100, 550, 600);


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

JPanel2.setBorder(BorderFactory.createLineBorder(Color.green));

JPanel3.setBorder(BorderFactory.createLineBorder(Color.blue));

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

JPanel5.setBorder(BorderFactory.createLineBorder(Color.green));

JPanel6.setBorder(BorderFactory.createLineBorder(Color.blue));


this.add(JPanel1);

this.add(JPanel2);

this.add(JPanel3);

this.add(JPanel4);

this.add(JPanel5);

this.add(JPanel6);

/* operation,中文意思是手術(shù)、運(yùn)行。 */


/* EXIT:(出口; 通道; 太平門; 安全門; 離去; 出去; )(退出; 死亡; 退場) */

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


/* visible:可見的。set:設(shè)置 */

this.setVisible(true);

// this.setTitle("登錄后的界面");

// this.setLayout(null);

// this.setSize(800, 800);

// this.setLocationRelativeTo(null);

// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// this.setVisible(true);

}

}


/* implements:實(shí)現(xiàn) */

class shijian_zc implements ActionListener, TreeSelectionListener {


public ChengGongDengLuHouDejiemian dd = null;


public shijian_zc(ChengGongDengLuHouDejiemian d) {

dd = d;

}


/* actionPerformed:按鈕單擊方法。ActionEvent:動(dòng)作事件 */

@Override

public void actionPerformed(ActionEvent arg0) {

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


dd.JPanel3.setVisible(true);// 讓jp3的區(qū)域顯示,其他的區(qū)域隱藏

dd.JPanel4.setVisible(false);

dd.JPanel5.setVisible(false);

dd.JPanel6.setVisible(false);

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


dd.JPanel4.setVisible(true);// 讓jp4的區(qū)域顯示,其他的區(qū)域隱藏

dd.JPanel3.setVisible(false);

dd.JPanel5.setVisible(false);

dd.JPanel6.setVisible(false);

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


dd.JPanel5.setVisible(true);// 讓jp5的區(qū)域顯示,其他的區(qū)域隱藏

dd.JPanel4.setVisible(false);

dd.JPanel3.setVisible(false);

dd.JPanel6.setVisible(false);

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


dd.JPanel6.setVisible(true);// 讓jp6的區(qū)域顯示,其他的區(qū)域隱藏

dd.JPanel4.setVisible(false);

dd.JPanel5.setVisible(false);

dd.JPanel3.setVisible(false);

}


}


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

@Override

/* value(值)Changed(被改變) */

public void valueChanged(TreeSelectionEvent arg0) {

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

DefaultMutableTreeNode str = (DefaultMutableTreeNode) dd.JTree1

.getLastSelectedPathComponent();

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

if (str.toString().equals("增加用戶")) {

// Visible:可見的(;看得見的;有形商品的;明顯的;易察覺的;公眾場合出現(xiàn)多的)

dd.JPanel3.setVisible(true);// 讓jp3的區(qū)域顯示,其他的區(qū)域隱藏

dd.JPanel4.setVisible(false);

dd.JPanel5.setVisible(false);

dd.JPanel6.setVisible(false);

} else if (str.toString().equals("修改用戶")) {

dd.JPanel4.setVisible(true);// 讓jp4的區(qū)域顯示,其他的區(qū)域隱藏

dd.JPanel3.setVisible(false);

dd.JPanel5.setVisible(false);

dd.JPanel6.setVisible(false);

} else if (str.toString().equals("刪除用戶")) {

dd.JPanel5.setVisible(true);// 讓jp5的區(qū)域顯示,其他的區(qū)域隱藏

dd.JPanel4.setVisible(false);

dd.JPanel3.setVisible(false);

dd.JPanel6.setVisible(false);

} else if (str.toString().equals("查詢用戶")) {


dd.JPanel6.setVisible(true);// 讓jp6的區(qū)域顯示,其他的區(qū)域隱藏

dd.JPanel4.setVisible(false);

dd.JPanel5.setVisible(false);

dd.JPanel3.setVisible(false);

}

}

}




Java Swing解析版:圖書管理系統(tǒng)(2)實(shí)戰(zhàn)項(xiàng)目開發(fā)的評論 (共 條)

分享到微博請遵守國家法律
甘德县| 霍林郭勒市| 库伦旗| 建平县| 麟游县| 潜江市| 盐津县| 汉沽区| 郯城县| 呈贡县| 新乡县| 伊通| 合肥市| 迁西县| 陇西县| 桂阳县| 浦城县| 宿州市| 龙游县| 云南省| 太仆寺旗| 东至县| 金溪县| 米林县| 云龙县| 马龙县| 弋阳县| 通道| 襄汾县| 太白县| 莱阳市| 渝中区| 利津县| 陵川县| 买车| 介休市| 太和县| 汶上县| 丰台区| 门头沟区| 中阳县|