【发布时间】:2013-06-09 02:36:37
【问题描述】:
您好,我在运行程序时收到 Nullpointer 错误。我在这个网站上发现了一篇我认为可以解决问题的帖子Null Pointer Exception from JCalander Combobox 我使用了这个页面上的建议,但仍然收到错误消息。谁能告诉我哪里出错了?
String end;
if (jTimeButton3 != null) {
SimpleDateFormat dateFormatTime2 = new SimpleDateFormat("hh:mm a");
end = dateFormatTime2.format(jTimeButton3.getTargetDate());
endTime.setText(end);
} else {
JOptionPane.showMessageDialog(
null, "Please select a End Time.");
return;
}
【问题讨论】:
-
请发布
NullPointerException的stacktrace -
发布一个堆栈跟踪,并完成您的代码,好吗?
-
如需更好的帮助,请尽快发帖SSCCE
-
错误在此代码的第 4 行
-
@Reimeus 更像是 jTimeButton3.getTargetDate() 为空。他已经对 jTimeButton3 进行了空检查。
标签: java swing nullpointerexception simpledateformat