All your code is performing some processing during an event handling. In Java this is a problem, the GUI only gets drawn once all the event handling is processed. Besides that, it would be great to see the code for your JFrame, it probably does not add the Label before calling pack()
JLabel text is not displayed
-
25-09-2022 - |
Question
I added JLabel
on JFrame
and displayed frame on YES button click of JOptionPane
, it displays frame but didn't display label text.
int yes = JOptionPane.showConfirmDialog(null,"Do you want to reactivate previous
schedule(s)","Reactivate Schedule",JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE);
if(yes == JOptionPane.OK_OPTION) {
setVisible(false);
disp_wait.setVisible(true);
for(int i=0 ; i<options.taskList.size(); i++) {
dataList = Options.getInstance().getTaskList();
Task task=dataList.get(i);
boolean active = task.getActive();
if(active) {
task.setActive(true);
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
ex.getMessage();
}
}
}
}
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow