java通讯录连接mysql数据库

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

package jdbc;

import java.awt.Container;

import java.awt.FlowLayout;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import javax.swing.*;

public class Denglu extends WindowAdapter implements ActionListener {

JFrame f=new JFrame("登录");

Container c = f.getContentPane();

JLabel I=new JLabel("账号:",JLabel.CENTER);

JLabel P=new JLabel("密码:",JLabel.CENTER);

JTextField tI=new JTextField(11);

JPasswordField tP=new JPasswordField(11);

JButton confirm=new JButton("确定");

JButton cancel=new JButton("取消");

JPanel p1=new JPanel(new FlowLayout(FlowLayout.CENTER,7,3));

JPanel p2=new JPanel(new FlowLayout(FlowLayout.CENTER,7,3));

JPanel p3=new JPanel(new FlowLayout(FlowLayout.CENTER,7,0));

String ID="";

String PW="";

Object[] option = new Object[]{"查询","新建"};

public Denglu(){

tP.setEchoChar('*');

c.setLayout(new GridLayout(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);

}

public static void main(String[] args) {

new Denglu();

}

public void windowClosing(WindowEvent e){

System.exit(0);

}

public void actionPerformed(ActionEvent e) {

if (e.getSource()==confirm) {

if (ID.equals(tI.getText())&&PW.equals(new String(tP.getPassword()))) {

f.dispose();

JOptionPane.showMessageDialog(null, "登录成功", "提示",RMA TION_MESSAGE);

new ChioceDialog();

} else {

JOptionPane.showMessageDialog(null, "用户名或密码错误,请重新登录", "提示",JOptionPane.ERROR_MESSAGE);

}

}else if (e.getSource()==cancel) {

System.exit(1);

}

}

}

class ChioceDialog extends WindowAdapter implements ActionListener{

int newx = 0;

New newone = null;

Reference reference =null;

JDialog jDialog = new JDialog();

JButton referButton = new JButton("查询"); JButton newButton = new JButton("新建");

String name;

public ChioceDialog(){

Container container = jDialog.getContentPane();

jDialog.setBounds(300,120,240,60);

jDialog.setTitle("通讯录");

container.setLayout(new GridLayout(1,2,20,10));

container.add(referButton);

container.add(newButton);

jDialog.setVisible(true);

jDialog.validate();

newButton.addActionListener(this);

referButton.addActionListener(this);

jDialog.addWindowListener(this);

}

public void windowClosing (WindowEvent e){ if (newx == 1) {

reference.close();

}else if (newx == 2) {

newone.close();

}

System.exit(1);

}

public void actionPerformed(ActionEvent d) { if (d.getSource()==referButton) {

try {

reference = new Reference();

newx = 1;

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}else if(d.getSource()==newButton) {

try {

newone = new New();

newx = 2;

相关文档
最新文档