문제

I added JLabel on JFrame and displayed frame on YES button click of JOptionPane, it displays frame but didn't display label text.

enter image description here

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

enter image description here

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top