Java课程设计通讯录Word文档格式.docx

上传人:b****6 文档编号:19839588 上传时间:2023-01-10 格式:DOCX 页数:49 大小:25.74KB
下载 相关 举报
Java课程设计通讯录Word文档格式.docx_第1页
第1页 / 共49页
Java课程设计通讯录Word文档格式.docx_第2页
第2页 / 共49页
Java课程设计通讯录Word文档格式.docx_第3页
第3页 / 共49页
Java课程设计通讯录Word文档格式.docx_第4页
第4页 / 共49页
Java课程设计通讯录Word文档格式.docx_第5页
第5页 / 共49页
点击查看更多>>
下载资源
资源描述

Java课程设计通讯录Word文档格式.docx

《Java课程设计通讯录Word文档格式.docx》由会员分享,可在线阅读,更多相关《Java课程设计通讯录Word文档格式.docx(49页珍藏版)》请在冰豆网上搜索。

Java课程设计通讯录Word文档格式.docx

boxV1.add(Box.createVerticalStrut(8));

b1=newButton("

信息查询"

);

b1.setBackground(Color.pink);

b1.setFont(font);

boxV1.add(b1);

b2=newButton("

信息管理"

b2.setBackground(Color.pink);

b2.setFont(font);

boxV1.add(b2);

b3=newButton("

退出系统"

b3.setBackground(Color.pink);

b3.setFont(font);

boxV1.add(b3);

b1.addActionListener(this);

b2.addActionListener(this);

b3.addActionListener(this);

baseBox=Box.createHorizontalBox();

baseBox.add(boxV1);

baseBox.add(Box.createHorizontalStrut(10));

setLayout(newFlowLayout());

add(baseBox);

setBounds(125,125,450,280);

setVisible(true);

setResizable(false);

//窗口不可调整

addWindowListener(

newWindowAdapter()

{

publicvoidwindowClosing(WindowEvente)

{

System.exit(0);

}

}

);

}

publicvoidactionPerformed(ActionEvente)

{

Stringcmd=e.getActionCommand();

if(cmd.equals("

))

newsearch();

else

newmanager();

if(cmd.equals("

System.exit(0);

publicstaticvoidmain(Stringargs[])

{

newPhone();

}

/////////////////////*查询*///////////////////////////////

classsearchextendsFrameimplementsActionListener

{

Buttonb1,b2,b3,b4,b5;

BoxbaseBox,boxV1;

search()

Fontfont=newFont("

显示全部信息"

按姓名查询"

按地址查询"

b4=newButton("

关键字查询"

b4.setBackground(Color.pink);

b4.setFont(font);

boxV1.add(b4);

b5=newButton("

退出查询"

b5.setBackground(Color.pink);

b5.setFont(font);

boxV1.add(b5);

b4.addActionListener(this);

b5.addActionListener(this);

setVisible(false);

publicvoidactionPerformed(ActionEvente)

newall();

elseif(cmd.equals("

newname();

elseif(cmd.equals("

newaddress();

else

if(cmd.equals("

newchazhao();

intresult=JOptionPane.showOptionDialog(null,"

是否真的退出查询?

"

"

系统提示"

JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,

null,newString[]{"

确定"

取消"

},"

if(result==JOptionPane.YES_OPTION)

{

this.setVisible(false);

////////////////////////////显示数据库中已有的全部信息//////////////////////////////

classallextendsFrameimplementsActionListener

Buttonb1,b2;

BoxbaseBox,boxV1,boxV2;

ScrollPanescrollpane=newScrollPane(ScrollPane.SCROLLBARS_ALWAYS);

JTablejtable=newJTable();

JScrollPanejscrollpane=newJScrollPane(jtable);

//将表格加个滚动条

all()

显示"

boxV2=Box.createVerticalBox();

退出"

boxV2.add(b2);

boxV2.add(Box.createVerticalStrut(8));

baseBox.add(boxV2);

Stringcmd=e.getActionCommand();

if(cmd.equals("

String[]col={"

姓名"

"

地址"

职业"

手机"

住宅电话"

办公电话"

单位"

E-mail"

备注"

};

DefaultTableModelmm=newDefaultTableModel(col,0);

//定义一个表的模板

try

Class.forName("

sun.jdbc.odbc.JdbcOdbcDriver"

//加载access数据库驱

Connectionconn=DriverManager.getConnection("

jdbc:

odbc:

通讯录"

admin"

1111"

Statementstmt=conn.createStatement();

jscrollpane.setVisible(true);

ResultSetrs=stmt.executeQuery("

SELECT*FROM通讯录数据包"

//将查询得到的结果集给rs

while(rs.next())

Stringname=rs.getString

(1);

Stringaddress=rs.getString

(2);

Stringzy=rs.getString(3);

Stringphone=rs.getString(4);

Stringtel=rs.getString(5);

Stringbtel=rs.getString(6);

Stringdw=rs.getString(7);

Stringem=rs.getString(8);

Stringbz=rs.getString(9);

String[]row={name,address,zy,phone,tel,btel,dw,em,bz};

//将一行的数据存在row字符串数组里

mm.addRow(row);

//添加在表模板中

jtable.setModel(mm);

//将jtable这个表设置为刚刚定义的模板

jtable.setPreferredScrollableViewportSize(newDimension(1000,400));

scrollpane.setSize(380,150);

scrollpane.add(jscrollpane);

add(scrollpane);

jscrollpane.setVisible(true);

validate();

//将加载了表的滚动条在中显示

}catch(Exceptione1){}

intresult=JOptionPane.showOptionDialog(null,"

}

/////////////////////////////按姓名查找///////////////////////////////////

classnameextendsFrameimplementsActionListener

BoxbaseBox,boxV1,boxV2,boxV3,boxV4;

TextFieldtt;

name()

boxV1=Box.createVerticalBox();

label=newLabel("

请输入要查找的联系人姓名"

boxV1.add(label);

boxV1.add(Box.createVerticalStrut(8));

boxV2=Box.createVerticalBox();

tt=newTextField(12);

boxV2.add(tt);

boxV3=Box.createVerticalBox();

查询"

b1.setBackground(Color.pink);

boxV3.add(b1);

boxV3.add(Box.createVerticalStrut(8));

boxV4=Box.createVerticalBox();

退出"

b2.setBackground(Color.pink);

boxV4.add(b2);

boxV4.add(Box.createVerticalStrut(8));

baseBox.add(boxV2);

baseBox.add(boxV3);

baseBox.add(boxV4);

setResizable(false);

intn=0;

Stringss=tt.getText();

SELECT*FROM通讯录数据包"

if(name.equals(ss))

{

//将一行的数据存在row字符串数组里

n++;

//添加在表模板

}

if(n<

=0)

JOptionPane.showMessageDialog(null,"

信息不存在!

验证错误"

JOptionPane.ERROR_MESSAGE);

intresult=JOptionPane.showOptionDialog(null,"

是否现在添加?

是"

否"

if(result==JOptionPane.YES_OPTION)

{

newadd();

}

else

this.setVisible(false);

//将jtable这个表设置为刚刚定义的模板

jtable.setPreferredScrollableViewportSize(newDimension(950,200));

if

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 党团建设

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1