Frage

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

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top