1、java通讯录目 录一、 设计目的1二、 功能介绍2三、 程序流程2四、 设计步骤3五、 设计总结7六、 程序清单10七、 参考文献25一、设计目的 通过课程设计,提高理论和实际相结合来解决实际问题的能力,也使自己对基于面向对象的理论进行系统设计过程中的诸多具体问题有感性的认识和深入的理解,进而提高自己的学习兴趣为将来顺利进入毕业环节做必要的准备。二、功能介绍(1)具有新用户注册功能。(2)具有注册用户登录功能。(3)具有数据的录入功能。(4)具有数据查询功能,可以实现查询全部信息和按条件执行查询。(5)具有按条件删除数据功能。(6)具有统计功能三、程序流程 四、设计步骤 登录界面 publi
2、c Login(Display display, int style) super(display, style); setImage(org.eclipse.wb.swt.ResourceManager.getPluginImage(zui, icons/13.gif); createContents(); setBackgroundImage(ResourceManager.getPluginImage(Activator.getDefault(), icons/2372629_224209091_2.jpg); setBackgroundMode(SWT.INHERIT_DEFAULT)
3、; 创建一个view1类作为工具栏public void createPartControl(Composite parent) Composite container = new Composite(parent, SWT.NONE); Button btnNewButton = new Button(container, SWT.BORDER); btnNewButton.addSelectionListener(new SelectionAdapter() 新名片录入类Luru,包括人名,年龄,电话,属相,星座的录入,点击提交按钮把数据导入数据库。public void widgetSe
4、lected(SelectionEvent e) / 将信息存入数据库 String sql=insert into tongxun(name,age,tel,shuxiang,xingzuo) + values+ (+text.getText()+,+text_1.getText()+,+text_2.getText()+,+text_3.getText()+,+text_4.getText()+); System.out.println(sql); DBHelper db=new DBHelper(); db.update(sql); public void widgetSelected(
5、SelectionEvent e) / 选择操作行,右键点修改弹出shell TableItem items = table.getSelection(); if (items.length = 0) MessageDialog.openInformation(RUtil.getShell(), 操作有误, 请选择要修改的行!); else TableItem item = items0; String name = item.getText(0); try Display display = Display.getDefault(); Xiugai shell = new Xiugai(di
6、splay, SWT.SHELL_TRIM); shell.open(); shell.layout(); shell.fillText(name); while (!shell.isDisposed() if (!display.readAndDispatch() display.sleep(); catch (Exception e1) e1.printStackTrace(); );创建的查询类chaxun,可以按条件查询,按姓名查询,按星座查询,按电话查询,及统计所有联系人,查询出的联系人在表格中显示,右键单击所要修改或删除的人的信息,会弹出修改窗口如下创建一个修改类Xiugai,所选
7、择的联系人按右键修改此人信息,按确定键提交入数据库。public void widgetSelected(SelectionEvent e) String name = text.getText(); String age =text_1.getText(); String tel=text_2.getText(); String shuxiang=text_3.getText(); String xingzuo=text_4.getText(); if(name.equals() MessageDialog.openInformation(RUtil.getShell(), 信息不能为空,
8、数据不能为空!); return ; 新用户注册类Zhuce,按确定键提交入数据库。五、设计总结此次课程设计做完之后,对自己的实际操作能力起到了提高,比较理想地完成了课程设计所要求的所有任务。我觉得需求分析是很重要的,就拿这次的题目来说,一个清晰的需求分析能让我省去很多工作,能让我把代码写的更清晰,让我的代码能有更好的重用性,以此简化程序。而这次的题目其实也算不上需求分析,只能算是功能分析吧。从界面到用户登陆判断,从增删改查基本功能到文件读写。如果能够把代码细化,把基本功能都封装成函数,这样应该会提高代码的重用性。另外程序虽然完成了所有功能,但是还具有不严密性,易出错性,在今后应该更加丰富自己
9、的知识,把程序写得更加完美。六、程序清单查询类:package editors;import java.sql.ResultSet;import org.eclipse.core.runtime.IProgressMonitor;import org.eclipse.jface.dialogs.MessageDialog;import org.eclipse.swt.SWT;import org.eclipse.swt.widgets.Composite;import org.eclipse.ui.IEditorInput;import org.eclipse.ui.IEditorSite;i
10、mport org.eclipse.ui.PartInitException;import org.eclipse.ui.part.EditorPart;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.Label;import org.eclipse.swt.widgets.Text;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.Table;import org.eclipse.swt.widgets.Table
11、Item;import org.eclipse.swt.widgets.TableColumn;import org.eclipse.swt.events.SelectionAdapter;import org.eclipse.swt.events.SelectionEvent;import common.DBHelper;import common.RUtil;import org.eclipse.swt.widgets.Menu;import org.eclipse.swt.widgets.MenuItem;public class Chaxun extends EditorPart pu
12、blic static final String ID = editors.Chaxun; /$NON-NLS-1$ private Text text; private Text text_1; private Table table; private Text text_2; public Chaxun() /* * Create contents of the editor part. * param parent */ Override public void createPartControl(Composite parent) Composite container = new C
13、omposite(parent, SWT.NONE); Label lblNewLabel = new Label(container, SWT.NONE); lblNewLabel.setBounds(117, 58, 88, 18); lblNewLabel.setText(u6309u59D3u540Du67E5u627E); Label lblid = new Label(container, SWT.NONE); lblid.setText(u6309u661Fu5EA7u67E5u627E); lblid.setBounds(117, 93, 88, 18); Label label_1 = new Label(container, SWT.NONE); label_1.setText(u6309u7535u8BDDu67E5u627E); label_1.setBounds(117, 130, 88, 18); text = new Text(container, SWT.BORDER); text.setBounds(214, 58, 88, 18); text_1 = new Text(container, SWT.BORDER);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1