Java课程设计 - 学生通讯录管理系统(7)

2019-08-31 09:36

}

}

String key = keywordText.getText(); InformationDao oneInformation=new ArrayList lis =

Vector head = new Vector(); head.add(\学号\); head.add(\姓名\); head.add(\手机号码\); head.add(\性别\);

head.add(\系别\);

Vector content = new Vector(); for (int i = 0; i < lis.size(); i++) { }

DefaultTableModel model = new table.setModel(model); repaint();

Vector row = new Vector();

Information oneInformation1 = (Information) row.add(oneInformation1.getSnum()); row.add(oneInformation1.getSname()); row.add(oneInformation1.getPhonumber()); row.add(oneInformation1.getSex()); row.add(oneInformation1.getDept()); content.add(row);

InformationDao();

oneInformation.queryInformation(key);

lis.get(i);

DefaultTableModel(content, head);

class CloseListener implements ActionListener{ }

public static void main(String[] args) { }

new InformationQueryUI();

public void actionPerformed(ActionEvent e) { }

dispose();

}

执行截图如下:

(9)InformationAddUI类:此类为添加学生基本信息界面类,在此界面中有五个标签,五个文本框,还有两个按钮“添加”“退出”。根据五个标签的提示,分别在五个文本框中输入信息。当单击“添加”按钮时,通过注册事件,在内部类的actionPerformed()方法中,获取五个文本框中的信息,并转换成相应的基本数据类型,通过InformationDao类的addInformation()方法,将数据写入数据库的information表中。若添加成功,提示成功,否则提示失败。 InformationAddUI类源代码:

package ui; import java.awt.*; import java.awt.event.*; import javax.swing.*; import Dao.InformationDao;

public class InformationAddUI extends JFrame{

JLabel l1, l2, l3, l4, l5; JTextField t1, t2, t3, t4, t5; JButton bt1, bt2;

public InformationAddUI(){

l1 = new JLabel(\学号\); l2 = new JLabel(\姓名\);

l3 = new JLabel(\手机号码\); l4 = new JLabel(\性别\); l5 = new JLabel(\系别\); t1 = new JTextField(20); t2 = new JTextField(20); t3 = new JTextField(20); t4 = new JTextField(20); t5 = new JTextField(20); bt1 = new JButton(\添加\); bt2 = new JButton(\退出\); JPanel p1 = new JPanel(); p1.setLayout(null);

l1.setBounds(100, 100, 80, 30); p1.add(l1);

t1.setBounds(170, 100, 100, 30); p1.add(t1);

l2.setBounds(100, 140, 80, 30); p1.add(l2);

t2.setBounds(170, 140, 200, 30); p1.add(t2);

l3.setBounds(100, 180, 80, 30); p1.add(l3);

t3.setBounds(170, 180, 200, 30); p1.add(t3);

l4.setBounds(100, 220, 80, 30); p1.add(l4);

t4.setBounds(170, 220, 200, 30); p1.add(t4);

l5.setBounds(100, 260, 80, 30); p1.add(l5);

t5.setBounds(170, 260, 60, 30); p1.add(t5);

bt1.setBounds(140, 300, 80, 30); p1.add(bt1);

bt2.setBounds(280, 300, 80, 30); p1.add(bt2);

bt1.addActionListener(new AddListener());

bt2.addActionListener(new CloseListener()); this.setBounds(200, 200, p1.getHeight(), this.add(p1);

this.setTitle(\添加信息界面\); this.setSize(400, 400); this.setVisible(true);

this.addWindowListener(new WindowAdapter() {// 匿

public void windowClosing(WindowEvent e)

p1.getHeight());

名类开始

// 把退出窗口的语句写在本方法中 {

}

class AddListener implements ActionListener{

public void actionPerformed(ActionEvent arg0) {

InformationDao oneInformationDao = new int snum = Integer.parseInt(t1.getText()); String sname = t2.getText(); String phonumber = t3.getText(); String sex = t4.getText(); String dept = t5.getText(); boolean issuccess =

}

dispose();

});

InformationDao();

oneInformationDao.addInformation(snum, sname,phonumber,sex,dept); if (issuccess) {

JOptionPane.showMessageDialog(null,

\, \提示信息\, JOptionPane.INFORMATION_MESSAGE);

t1.setText(\); t2.setText(\); t3.setText(\); t4.setText(\); t5.setText(\);

} else {

JOptionPane.showMessageDialog(null,

\, \提示信息\, JOptionPane.INFORMATION_MESSAGE);

}

class CloseListener implements ActionListener{ }

public static void main(String[] args) { } }

new InformationAddUI();

public void actionPerformed(ActionEvent e) { }

dispose(); }

}

执行截图如下:


Java课程设计 - 学生通讯录管理系统(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:躲避球策划

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: