java通讯录连接mysql数据库文档格式.docx
- 文档编号:14968039
- 上传时间:2022-10-26
- 格式:DOCX
- 页数:18
- 大小:18.26KB
java通讯录连接mysql数据库文档格式.docx
《java通讯录连接mysql数据库文档格式.docx》由会员分享,可在线阅读,更多相关《java通讯录连接mysql数据库文档格式.docx(18页珍藏版)》请在冰豆网上搜索。
JLabelI=newJLabel("
账号:
"
JLabel.CENTER);
JLabelP=newJLabel("
密码:
JTextFieldtI=newJTextField(11);
JPasswordFieldtP=newJPasswordField(11);
JButtonconfirm=newJButton("
确定"
JButtoncancel=newJButton("
取消"
JPanelp1=newJPanel(newFlowLayout(FlowLayout.CENTER,7,3));
JPanelp2=newJPanel(newFlowLayout(FlowLayout.CENTER,7,3));
JPanelp3=newJPanel(newFlowLayout(FlowLayout.CENTER,7,0));
StringID="
;
StringPW="
Object[]option=newObject[]{"
查询"
"
新建"
};
publicDenglu(){
tP.setEchoChar('
*'
c.setLayout(newGridLayout(3,1));
p1.add(I);
p1.add(tI);
p2.add(P);
p2.add(tP);
p3.add(confirm);
p3.add(cancel);
f.add(p1);
f.add(p2);
f.add(p3);
f.setBounds(300,200,70,50);
f.setVisible(true);
f.pack();
confirm.addActionListener(this);
cancel.addActionListener(this);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
publicstaticvoidmain(String[]args){
newDenglu();
publicvoidwindowClosing(WindowEvente){
System.exit(0);
publicvoidactionPerformed(ActionEvente){
if(e.getSource()==confirm){
if(ID.equals(tI.getText())&
&
PW.equals(newString(tP.getPassword()))){
f.dispose();
JOptionPane.showMessageDialog(null,"
登录成功"
"
提示"
JOptionPane.INFORMATION_MESSAGE);
newChioceDialog();
}else{
用户名或密码错误,请重新登录"
JOptionPane.ERROR_MESSAGE);
}
}elseif(e.getSource()==cancel){
System.exit
(1);
}
classChioceDialogextendsWindowAdapterimplementsActionListener{
intnewx=0;
Newnewone=null;
Referencereference=null;
JDialogjDialog=newJDialog();
JButtonreferButton=newJButton("
JButtonnewButton=newJButton("
Stringname;
publicChioceDialog(){
Containercontainer=jDialog.getContentPane();
jDialog.setBounds(300,120,240,60);
jDialog.setTitle("
通讯录"
container.setLayout(newGridLayout(1,2,20,10));
container.add(referButton);
container.add(newButton);
jDialog.setVisible(true);
jDialog.validate();
newButton.addActionListener(this);
referButton.addActionListener(this);
jDialog.addWindowListener(this);
publicvoidwindowClosing(WindowEvente){
if(newx==1){
reference.close();
}elseif(newx==2){
newone.close();
}
System.exit
(1);
publicvoidactionPerformed(ActionEventd){
if(d.getSource()==referButton){
try{
reference=newReference();
newx=1;
}catch(Exceptione){
//TODOAuto-generatedcatchblock
e.printStackTrace();
}
}elseif(d.getSource()==newButton){
newone=newNew();
newx=2;
importjava.awt.*;
importjava.sql.Connection;
importjava.sql.DatabaseMetaData;
importjava.sql.DriverManager;
importjava.sql.ResultSet;
importjava.sql.Statement;
publicclassAddressBookextendsWindowAdapterimplementsActionListener{
Statementst=null;
Connectionconn;
ResultSetrsTables;
ResultSetrs;
Framef=newFrame("
Labeltitle=newLabel("
个人基本信息表"
Label.CENTER);
LabelqqLabel=newLabel("
QQ:
"
LabelnameLabel=newLabel("
姓名:
LabelsexLabel=newLabel("
性别:
LabeltelLabel=newLabel("
Tel:
LabelemaiLabel=newLabel("
Email:
LabelhobbyLabel=newLabel("
兴趣:
Labeladdtext=newLabel("
备注"
TextFieldnameTextField=newTextField(17);
TextFieldqqTextField=newTextField(17);
TextFieldtelTextField=newTextField(17);
TextFieldemailTextField=newTextField(17);
TextAreatext=newTextArea(4,3);
Buttonconfirm=newButton("
Buttonsubmit=newButton("
重置"
ButtonknowButton=newButton("
Panelp1=newPanel(newFlowLayout(FlowLayout.CENTER,10,3));
Panelp7=newPanel(newFlowLayout(FlowLayout.CENTER,10,3));
Panelp8=newPanel(newGridLayout(2,1));
Panelp3=newPanel(newBorderLayout(3,3));
Panelp2=newPanel(newFlowLayout(FlowLayout.CENTER,66,1));
Panelp4=newPanel(newBorderLayout());
Panelp5=newPanel(newFlo
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 通讯录 连接 mysql 数据库