}
}
String key = keywordText.getText(); InformationDao oneInformation=new ArrayList lis =
Vector
head.add(\系别\);
Vector
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(); }
}
执行截图如下: