java中ActionListener的问题
publicclassEmpHandleimplementsActionListener{EmpModelem=newEmpModel();EmpViewev=newEm...
public class EmpHandle implements ActionListener {
EmpModel em = new EmpModel();
EmpView ev = new EmpView();
public void actionPerformed( ActionEvent e) {
if (e.getActionCommand() == "增加") {
EmpModel em = new EmpModel();
EmpView ev = new EmpView();
String s1= ev.s1;
String s2 =ev.s2;
String s3= ev.s3;
String s4= ev.s4;
System.out.println(s1);
if (s1.length() == 0 || s2.length() == 0 || s3.length() == 0) {
JOptionPane.showMessageDialog(new JPanel(), "请输入信息", "错误",
JOptionPane.ERROR_MESSAGE);
}
else {
em.setEmpno(s1);
em.SetEname(s2);
em.SetPosition(s3);
em.SetRemarks(s4);
em.insert();
JOptionPane.showMessageDialog(new JPanel(), "添加成功", "添加",
JOptionPane.INFORMATION_MESSAGE);
}
}
补充:s1s2s3s4是从ev中获取文本框中的值,但是却得不到值,输出s1为空值
请高手指教 展开
EmpModel em = new EmpModel();
EmpView ev = new EmpView();
public void actionPerformed( ActionEvent e) {
if (e.getActionCommand() == "增加") {
EmpModel em = new EmpModel();
EmpView ev = new EmpView();
String s1= ev.s1;
String s2 =ev.s2;
String s3= ev.s3;
String s4= ev.s4;
System.out.println(s1);
if (s1.length() == 0 || s2.length() == 0 || s3.length() == 0) {
JOptionPane.showMessageDialog(new JPanel(), "请输入信息", "错误",
JOptionPane.ERROR_MESSAGE);
}
else {
em.setEmpno(s1);
em.SetEname(s2);
em.SetPosition(s3);
em.SetRemarks(s4);
em.insert();
JOptionPane.showMessageDialog(new JPanel(), "添加成功", "添加",
JOptionPane.INFORMATION_MESSAGE);
}
}
补充:s1s2s3s4是从ev中获取文本框中的值,但是却得不到值,输出s1为空值
请高手指教 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询