Java 如何设置JLabel?
我想将Java 如何设置JLabel?,java,swing,jframe,jlabel,event-dispatch-thread,Java,Swing,Jframe,Jlabel,Event Dispatch Thread,我想将JLabel设置为“下载…” 请在下面查找代码 if ((JButton) e.getSource() == download) { if (!(criteria.trim().equals("---Select Criteria---"))) { if (!(detailFileLocation.getText().trim().equals("") || detailFileLoca
JLabel
设置为“下载…”
请在下面查找代码
if ((JButton) e.getSource() == download) {
if (!(criteria.trim().equals("---Select Criteria---"))) {
if (!(detailFileLocation.getText().trim().equals("")
|| detailFileLocation.getText().trim().equals(null))) {
if (!(downloadFileLocation.getText().trim().equals("")
|| downloadFileLocation.getText().trim().equals(null))) {
// Actual content goes here
try {
status.setText("Downloading...");
count = DownloadFileNetDocument.processingDocument(objectStore, criteria,
detailFileLocation.getText(), downloadFileLocation.getText(), env);
detailFileLocation.setText("");
downloadFileLocation.setText("");
selectCriteria.setSelectedIndex(0);
if (count > 0) {
status.setText(count + " files downloaded successfully");
count = 0;
} else if (count == 0) {
status.setText("No files found");
}
} catch (Exception e1) {
status.setText("*** ERROR in downloading files ***");
}
} else {
status.setText("*** Please choose download path for property file ***");
}
} else {
status.setText("*** Please select the file containing the values ***");
}
} else {
status.setText("*** Please select a criteria to Download ***");
}
当我点击开始下载按钮,然后下载完成时,标签应设置为“文件下载成功”。但当我点击下载时,标签从未设置为“下载…”添加
状态。重新绘制()代码>在status.setText(“下载…”)之后代码>不应使用等于函数进行空检查。Rahter请使用downloadFileLocation.getText()==null,除非您想检查空字符串谢谢,我会记住这一点。:)但这并不能解决我的问题:(1)为了更快地得到更好的帮助,添加一个or。2) 不要阻止EDT(事件调度线程)。发生这种情况时,GUI将“冻结”。有关详细信息和修复方法,请参阅。