Panel text not showing in JFrame

  • Follow


I have a JFrame to display after a button is clicked. The following
JFrame appears, but the label text does not appear until the thread is
completed. Any advise:


public void run(){
 JPanel panel = new JPanel();  // create pane content object
 JLabel prompt = new JLabel("Processing log files");

panel.add(prompt);

Container contentPane = myFrame.getContentPane();
contentPane.add(panel);

myFrame.setTitle("Processing logs...Please Wait");
myFrame.setBounds(100,100,350,75); // position frame
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.toFront();
panel.add(prompt);
myFrame.setVisible(true);
myFrame.pack();
System.out.println ("pack1 done");
myFrame.repaint();
myFrame.pack();
}

0
Reply rjl444 (20) 2/10/2005 3:05:02 PM

Why are you putting these lines in the run() method?

The reason it's not displaying until the thread is completed is because
you set the JFrame visible near the end of run

0
Reply klynn47 2/10/2005 3:16:32 PM


I place this in a run as I tried threading this particular method, but
it did not make a difference. I also tried it in a regular method. What
is not showing is that I am processing a file (reading) immediately
after this method runs. The window appears immediatley, while the file
is read,  but the panel text waits until the file is read to show.I
want the panel to display 'please wait'
thanks for any additional help.

0
Reply rjl444 2/10/2005 3:28:53 PM

2 Replies
299 Views

(page loaded in 0.069 seconds)

Similiar Articles:













7/24/2012 10:48:17 AM


Reply: