简体   繁体   中英

JLabel text is not displayed

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();
                }
            }
        }
    }

在此处输入图片说明

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM