好文档 - 专业文书写作范文服务资料分享网站

JAVA通讯录(内含源代码)

天下 分享 时间: 加入收藏 我要投稿 点赞

}

}

public void actionPerformed(ActionEvent e) { if (e.getSource() == btn1) { for (int t = 0; t < i; t++) { if (uTxt2.getText().equals(str[t])) { str[t] = uTxt1.getText(); str6[t] = uTxt2.getText(); } this.dispose(); } } if (e.getSource() == btn2) { this.dispose(); } }

// 查询好友界面

public class Searchfriend extends JFrame implements ActionListener {

JLabel label; JTextField uTxt; JButton btn1, btn2;

Searchfriend() { this.setSize(400, 300); this.setTitle(\查询好友\ this.setLayout(null);

label = new JLabel(\好友名%uTxt = new JTextField(20); btn1 = new JButton(\查询\btn2 = new JButton(\退出\label.setBounds(80, 100, 60, 30); uTxt.setBounds(130, 100, 140, 30); btn1.setBounds(100, 200, 60, 30); btn2.setBounds(220, 200, 60, 30); this.add(label); this.add(uTxt); this.add(btn1);

}

}

this.add(btn2);

btn1.addActionListener(this); btn2.addActionListener(this); this.setLocationRelativeTo(null);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true);

public void actionPerformed(ActionEvent e) { if (e.getSource() == btn1) { for (int f = 0; f < j; f++) { if (uTxt.getText().equals(str1[f])) { t = f; new Revisefriend(f); } } this.dispose(); } if (e.getSource() == btn2) { this.dispose(); } }

// 增加好友界面

public class Addfriend extends JFrame implements ActionListener, ItemListener {

JTextField uTxt1, uTxt2, uTxt3, uTxt4;

JLabel Name, Tel, Phone, Address, BelongTo; JButton btn1, btn2; Choice cb;

ButtonGroup bg; JLabel sex;

JRadioButton male; JRadioButton female; Addfriend() { this.setSize(450, 600); this.setTitle(\增加好友\ this.setLayout(null);

Name = new JLabel(\姓名:\

Tel = new JLabel(\手机:\Phone = new JLabel(\电话:\Address = new JLabel(\地址:\BelongTo = new JLabel(\归属:\btn1 = new JButton(\增加\btn2 = new JButton(\取消%uTxt1 = new JTextField(20); uTxt2 = new JTextField(20); uTxt3 = new JTextField(20); uTxt4 = new JTextField(20); cb = new Choice(); for (int t = 0; t < i; t++) { cb.add(str[t]); }

cb.setBounds(120, 250, 180, 30); Name.setBounds(80, 50, 60, 30); Tel.setBounds(80, 100, 60, 30); Phone.setBounds(80, 150, 60, 30); Address.setBounds(80, 200, 60, 30); BelongTo.setBounds(80, 250, 60, 30); uTxt1.setBounds(120, 50, 180, 30); uTxt2.setBounds(120, 100, 180, 30); uTxt3.setBounds(120, 150, 180, 30); uTxt4.setBounds(120, 200, 180, 30); sex = new JLabel(\性别\

male = new JRadioButton(\男\female = new JRadioButton(\女\bg = new ButtonGroup(); bg.add(male); bg.add(female);

sex.setBounds(80, 330, 60, 30); male.setBounds(120, 400, 60, 30); female.setBounds(250, 400, 60, 30); btn1.setBounds(100, 500, 60, 30);

}

btn2.setBounds(250, 500, 60, 30); this.add(btn1); this.add(btn2); this.add(sex); this.add(male); this.add(female); this.add(Name); this.add(Tel); this.add(Phone); this.add(Address); this.add(BelongTo); this.add(cb); this.add(uTxt1); this.add(uTxt2); this.add(uTxt3); this.add(uTxt4);

btn1.addActionListener(this); btn2.addActionListener(this); cb.addItemListener(this); male.addActionListener(this); female.addActionListener(this);

this.setLocationRelativeTo(null);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true);

public void actionPerformed(ActionEvent e) { if (e.getSource() == btn1) { str1[j] = uTxt1.getText(); str2[j] = uTxt2.getText(); str3[j] = uTxt3.getText(); str4[j] = uTxt4.getText(); j++; this.dispose(); } if (e.getSource() == male) { str5[m] = true;

}

}

m++; }

if (e.getSource() == female) { str5[m] = false; m++; }

if (e.getSource() == btn2) { this.dispose(); }

public void itemStateChanged(ItemEvent e) { }

str6[k] = cb.getSelectedItem(); k++;

// 修改好友信息界面

public class Revisefriend extends JFrame implements ActionListener, ItemListener {

JTextField uTxt1, uTxt2, uTxt3, uTxt4;

JLabel Name, Tel, Phone, Address, BelongTo; Choice cb;

ButtonGroup bg; JButton btn1, btn2;

JRadioButton male, female; JLabel sex; int t = 0;

Revisefriend(int b) { this.t = b; this.setSize(400, 600); this.setTitle(\好友信息\ this.setLayout(null);

Name = new JLabel(\姓名:\Tel = new JLabel(\手机:\Phone = new JLabel(\电话:\Address = new JLabel(\地址:\BelongTo = new JLabel(\归属:\

6rbqm56g379pugm7qnnb9acj39qpyw00el6
领取福利

微信扫码领取福利

微信扫码分享