当更新学生信息关闭时,它将刷新学生信息系统上的数据并清除搜索文本字段中的数据。请帮忙!
这是我尝试过的,但它不起作用!
public class UpdateInfo extends JFrame{
public JPanel pParent;
public JTextField jtfStudentID;
public JTextField jtfStudentName;
public JTextField jtfGender;
public JTextField jtfAddres;
private JButton updateButton;
private JButton cancelButton;
private StudentList stu;
public UpdateInfo() {
super("Update Student Information ");
setContentPane(pParent);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setPreferredSize(new Dimension(650, 350));
pack();
setLocationRelativeTo(null);
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stu = new StudentList();
stu.jtfSearch.setText("");
dispose();
}
});
}
}
答案 0 :(得分:0)
一种方法是在取消按钮上添加ActionListsner,这样当单击时,JFrame2将关闭,JTextField将设置为" "使用方法.setText
答案 1 :(得分:0)
JFrame有一个dispose_on_close操作。当jframe关闭时searchTextfield set' "" '和。如果在jframe后面有一张桌子。
DefaultTableModel.add(//新项目);
请与我们分享代码。