Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 请教:找不到数据!谢谢.
ttlweb





发贴: 6
积分: 0
于 2004-11-18 17:26 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
{原文件较大时,请考虑选择添付文件的方式}
BookManagerMain.java
代码:

/*
* 创建日期 2004-11-8
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/

/**
* @author
*
* TODO 要更改此生成的类型注释的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/

import java.awt.event.*;
//import java.applet.*;
//import java.awt.*;
import javax.swing.*;

public class BookManagerMain extends JFrame{
//声明基本组件
JMenuBar jmb1;
JMenu jm1,jm12,jm2,jm3,jm4,jm5;
JMenuItem jmi11,jmi12,jmi13,jmi121,jmi122,jmi123,jmi21,jmi22,jmi23,
jmi31,jmi32,jmi41,jmi42,jmi51,jmi52;

//调用相关操作类
UserLogin ul1;
UserAdd ua1;
UserUpdate uu1;
UserDelete ud1;
BookAdd ba1;
BookUpdate bu1;
BookDelete bd1;
BorrowBook bb1;
BorrowInfoUpdate biu1;
ReturnBook rb1;
ReturnInfoUpdate riu1;
BookList bl1;
ReaderList rl1;

//构造窗体
public BookManagerMain(){

//2004-11-13 Roger。Lu
//
//这里只要生成框架;
//只有当点击菜单时才要用本类实例,同时要保证在整个系统运行时实例的唯一性。
// 注册监听
// JMenuItem jmi11.addActionListener(new jmi11ActionAdapter(this));
// 处理监听
// class jmi11ActionAdapter implements ActionListener{
// BookManagerMain bmm1;
// public jmi11ActionAdapter(BookManagerMain bmm1) {
// this.bmm1=bmm1;
// }
// public void actionPerformed(ActionEvent e){
// ul1=new UserLogin("用户登陆");
// ul1.setLocation(100,100);
// }
// }

//窗口画好后,控制菜单的组件可视化的问题
//因为本质上是BookMainManagerMain本身的问题
//所以添加setEnable()方法
//同时添加对窗口的监听
//当本类被实例化的时候,通过对打开窗口时调用该方法实现

//画窗口
this.setTitle("书籍管理系统V1.0");
jmb1=new JMenuBar();
jm1=new JMenu("系统管理");
jm12=new JMenu("用户管理");
jm2=new JMenu("书籍管理");
jm3=new JMenu("借书管理");
jm4=new JMenu("还书管理");
jm5=new JMenu("信息一览");
jmi11=new JMenuItem("用户登陆");
jmi121=new JMenuItem("添加用户");
jmi122=new JMenuItem("修改用户");
jmi123=new JMenuItem("删除用户");
jmi13=new JMenuItem("退出");
jmi21=new JMenuItem("添加书籍信息");
jmi22=new JMenuItem("修改书籍信息");
jmi23=new JMenuItem("删除书籍信息");
jmi31=new JMenuItem("书籍出借");
jmi32=new JMenuItem("出借信息修改");
jmi41=new JMenuItem("书籍还入");
jmi42=new JMenuItem("书籍还入信息修改");
jmi51=new JMenuItem("书籍列表");
jmi52=new JMenuItem("借阅者列表");
//注册监听
this.addWindowListener(new windowActionAdater(this));
jmi11.addActionListener(new jmi11ActionAdapter(this));
jmi121.addActionListener(new jmi121ActionAdapter(this));
jmi122.addActionListener(new jmi122ActionAdapter(this));
jmi123.addActionListener(new jmi123ActionAdapter(this));
jmi13.addActionListener(new jmi13ActionAdapter(this));
jmi21.addActionListener(new jmi21ActionAdapter(this));
jmi22.addActionListener(new jmi22ActionAdapter(this));
jmi23.addActionListener(new jmi23ActionAdapter(this));
jmi31.addActionListener(new jmi31ActionAdapter(this));
jmi32.addActionListener(new jmi32ActionAdapter(this));
jmi41.addActionListener(new jmi41ActionAdapter(this));;
jmi42.addActionListener(new jmi42ActionAdapter(this));
jmi51.addActionListener(new jmi51ActionAdapter(this));
jmi52.addActionListener(new jmi52ActionAdapter(this));;
//组件安装
jm1.add(jmi11);
jm1.add(jm12);
jm12.add(jmi121);
jm12.add(jmi122);
jm12.add(jmi123);
jm1.add(jmi13);
jm2.add(jmi21);
jm2.add(jmi22);
jm2.add(jmi23);
jm3.add(jmi31);
jm3.add(jmi32);
jm4.add(jmi41);
jm4.add(jmi42);
jm5.add(jmi51);
jm5.add(jmi52);
jmb1.add(jm1);
jmb1.add(jm2);
jmb1.add(jm3);
jmb1.add(jm4);
jmb1.add(jm5);
this.setJMenuBar(jmb1);
//可视化
this.setBounds(50,50,600,400);
this.setVisible(true);
this.validate();
}

//组件可视化控制
public void setEnable(String s1) {
if(s1=="yh_p_1") {
jm12.setEnabled(true);
jm2.setEnabled(true);
jm3.setEnabled(true);
jm4.setEnabled(true);
jm5.setEnabled(true);
}
else if(s1=="yh_p_2") {
jm12.setEnabled(false);
jm2.setEnabled(true);
jm3.setEnabled(false);
jm4.setEnabled(false);
jm5.setEnabled(true);
}
else if(s1=="yh_p_3") {
jm12.setEnabled(false);
jm2.setEnabled(false);
jm3.setEnabled(true);
jm4.setEnabled(true);
jm5.setEnabled(true);
}
else {
jm12.setEnabled(false);
jm2.setEnabled(false);
jm3.setEnabled(false);
jm4.setEnabled(false);
jm5.setEnabled(false);
}
}

//适配器类打开窗口,同时传递对象
private class jmi11ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi11ActionAdapter(BookManagerMain bmm1){
//接管框架传递的主类对象使之本地化
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
//传递本地对象到目标窗口
ul1=new UserLogin(this.bmm1,"用户登陆");
ul1.setLocation(100,100);
}
}

private class jmi121ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi121ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
ua1=new UserAdd("用户添加");
ua1.setLocation(110,110);
}
}

private class jmi122ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi122ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
uu1=new UserUpdate("用户修改");
uu1.setLocation(120,120);
}
}

private class jmi123ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi123ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
ud1=new UserDelete("用户删除");
ud1.setLocation(130,130);
}
}

private class jmi13ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi13ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
System.exit(0);
}
}

private class jmi21ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi21ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
ba1=new BookAdd("添加书籍信息");
ba1.setLocation(140,140);
}
}

private class jmi22ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi22ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
bu1=new BookUpdate("修改书籍信息");
bu1.setLocation(150,150);
}
}

private class jmi23ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi23ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
bd1=new BookDelete("删除书籍信息");
bd1.setLocation(160,160);
}
}

private class jmi31ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi31ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
bb1=new BorrowBook("书籍出借");
bb1.setLocation(170,170);
}
}

private class jmi32ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi32ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
biu1=new BorrowInfoUpdate("出借信息修改");
biu1.setLocation(180,180);
}
}

private class jmi41ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi41ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
rb1=new ReturnBook("书籍还入");
rb1.setLocation(190,190);
}
}

private class jmi42ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi42ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
riu1=new ReturnInfoUpdate("书籍还入信息修改");
riu1.setLocation(200,200);
}
}

private class jmi51ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi51ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
bl1=new BookList("书籍列表");
bl1.setLocation(210,210);
}
}

private class jmi52ActionAdapter implements ActionListener{
BookManagerMain bmm1;
public jmi52ActionAdapter(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void actionPerformed(ActionEvent e){
rl1=new ReaderList("借阅者列表");
rl1.setLocation(220,220);
}
}

private class windowActionAdater extends WindowAdapter {
BookManagerMain bmm1;
public windowActionAdater(BookManagerMain bmm1) {
this.bmm1=bmm1;
}
public void windowOpened(WindowEvent we){
setEnable("");
}
public void windowClosing(WindowEvent we){
System.exit(0);
}
}

//启动程序
public static void main(String[] args) {
new BookManagerMain();
}

}


littledeer1974 edited on 2004-11-18 21:49


JBuilder使用技巧

话题树型展开
人气 标题 作者 字数 发贴时间
16363 请教:找不到数据!谢谢. ttlweb 10450 2004-11-18 17:26
12100 Re:请教:找不到数据!谢谢. ttlweb 3482 2004-11-18 17:27
12002 Re:请教:找不到数据!谢谢. ttlweb 1997 2004-11-18 17:28
12136 Re:请教:找不到数据!谢谢. ttlweb 81 2004-11-18 17:29

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923