电话本的java程序代码 电话本的java程序代码怎么写( 三 )

setTitle("*通 讯 录 管 理 系 统*");
setVisible(true);
setResizable(false);//窗体大小由程序员决定,用户不能自由改变大小
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
/**
*按键响应
*
**/
button1.addActionListener(new ActionListener(){//添加功能实现
public void actionPerformed(ActionEvent arg0){
Infro.addFunction();
}
});
button2.addActionListener(new ActionListener(){//删除功能实现
public void actionPerformed(ActionEvent arg0){
Infro.deleteFunction();
}
});
button3.addActionListener(new ActionListener(){//修改功能实现
public void actionPerformed(ActionEvent arg0){
Infro.reditFunction();
}
});
button4.addActionListener(new ActionListener(){//查询功能实现
public void actionPerformed(ActionEvent arg0){
try {
Infro.searchFunction();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
button5.addActionListener(new ActionListener(){//显示功能实现
public void actionPerformed(ActionEvent arg0){
Infro.showFunction();
}
});
button6.addActionListener(new ActionListener(){//保存功能实现
public void actionPerformed(ActionEvent arg0){
try {
Infro.writeFunction();
} catch (IOException e) {
e.printStackTrace();
}
}
});
button7.addActionListener(new ActionListener(){//读取功能实现
public void actionPerformed(ActionEvent arg0){
try {
Infro.readFunction();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Demo();
Infro a = new Infro("", "", "", "", "", "");
}
}
关于Java如何实现通讯录管理系统就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识 。如果觉得文章不错,可以把它分享出去让更多的人看到 。
java 电话本程序只有最基本的功能,用户界面很粗糙,联系人明细也只有名字和一个电话,试着修改/增加一些功能以及配合数据库使用吧.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
@SuppressWarnings("serial")
public class PhoneBookDemo extends JFrame implements ActionListener,
PhoneBookDemoConstants {
private PhoneBook phoneBook;
JTextArea displayArea;
public PhoneBookDemo () {
phoneBook = new PhoneBookImpl();
displayArea = new JTextArea(20, 40);
displayArea.setEditable(false);
BoxLayout layout = new BoxLayout(getContentPane(), BoxLayout.Y_AXIS);
JPanel buttonPanel = new JPanel();
JButton addButton = new JButton(ADD_BUTTON_DISPLAY);
JButton searchButton = new JButton(SEARCH_BUTTON_DISPLAY);
JButton updateButton = new JButton(UPDATE_BUTTON_DISPLAY);
JButton removeButton = new JButton(REMOVE_BUTTON_DISPLAY);
addButton.addActionListener(this);
searchButton.addActionListener(this);
updateButton.addActionListener(this);
removeButton.addActionListener(this);
buttonPanel.add(addButton);
buttonPanel.add(searchButton);
buttonPanel.add(updateButton);
buttonPanel.add(removeButton);
display();
add(displayArea);
add(buttonPanel);
setLayout(layout);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(ADD_BUTTON_DISPLAY)) {

推荐阅读