我的java应用程序中有一个jFrame,它将选定的日期插入到数据库中。我想验证字段是否为空。
代码如下:
if(!this.jtxtDate.getSelectedItem.toString().isEmpty()) {
idc.setDate(this.jtxtDate.getDate);
} else {
JOptionPane.showMessageDialog(rootPane, "pls choose date");
}发布于 2019-02-20 07:58:19
DateChooser.setEnabled(假);
dateChooser.getCalendarButton().setEnabled(true);
因此,您无法编辑集成到JDateChooser中的文本字段。
发布于 2014-03-21 16:24:43
在try块中使用以下代码:
if(
((JTextField)jDateChooser1.getDateEditor().getUiComponent()).getText().isEmpty()
) {
JOptionPane.showMessageDialog(this, "Date should be filled");
} else {
//some code
}发布于 2017-05-08 07:18:10
你可以检查一下是否可以从jDateChooser获取日期。
if(this.jtxtDate.getDate() != null) {
idc.setDate(this.jtxtDate.getDate);
} else {
JOptionPane.showMessageDialog(rootPane, "pls choose date");
}https://stackoverflow.com/questions/19007738
复制相似问题