我想从数据库中获取记录并想在表单上设置。在这种形式中,我使用JDateChooser
from JCalendar
。我为此编写了以下代码:
public void showdata()
int a=leaveView.getSelectedRow();
int b=(Integer)leaveView.getValueAt(a, 0);
String c=(String)leaveView.getValueAt(a, 1);
String d=(String)leaveView.getValueAt(a, 2);
String e=(String)leaveView.getValueAt(a, 3);
String f=(String)leaveView.getValueAt(a, 4);
String g=(String)leaveView.getValueAt(a, 5);
String h=(String)leaveView.getValueAt(a, 6);
int i=(Integer)leaveView.getValueAt(a, 7);
String j = (String)leaveView.getValueAt(a, 8);
String k = (String)leaveView.getValueAt(a, 9);
AL.empid.setSelectedItem(b);
AL.empname.setText(c);
AL.empname.setEditable(true);
AL.department.setText(d);
AL.department.setEditable(true);
AL.leavetype.setSelectedItem(e);
AL.other.setText(f);
AL.other.setEditable(true);
AL.jDateChooser1.setDate(g);
AL.jDateChooser2.setDate(h);
AL.noofdays.setText(""+i);
AL.noofdays.setEditable(true);
AL.singleday.setSelected(true);
AL.multipleday.setSelected(true);
}
但它默认将今天的日期设置为JDateChooser
......它不显示从数据库中检索到的日期......上面的代码在行 AL.jDateChooser1.setDate(g)
和AL.jDateChooser2.setDate(h)
g & h 处引发错误......我该怎么办?