 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Gil Guest
|
Posted: Mon Apr 18, 2005 10:52 am Post subject: Pausing in a GUI |
|
|
I'm trying to display multiple frames with a pause of a few seconds
between
the display of each frame. I have the following code, but the swing
components of each frame will not appear before the pause starts. The
components only flash on the screen before the frame disappears and
the next frame appears which is also blank until just before it
appears.
Would anyone know what I might be doing wrong?
Thank you.
Gil
code :
Frame routine :
for (int i=0;i
FrameViewing fe = new FrameViewing(currFileList[i]);
fe.setSize(new Dimension(290,149));
fe.setLocation(345,90);
fe.setTitle("Frame :");
fe.setVisible(true);
fe.pause(5000);
fe.setVisible(false);
}
components set in FrameViewing constructor :
public FrameViewing(String filename) {
JPanel contentPane = (JPanel)this.getContentPane();
contentPane.setLayout(null);
// label
JLabel ds_l = new JLabel();
ds_l.setFont(new java.awt.Font("Dialog", 1, 14));
ds_l.setText("Filename :");
addComponent(contentPane, ds_l, 22,27, 190,20);
JLabel dsa_l = new JLabel();
dsa_l.setFont(new java.awt.Font("Dialog", 0, 12));
dsa_l.setText(filename);
addComponent(contentPane, dsa_l, 99,27, 190,20);
JLabel fet_l = new JLabel();
fet_l.setFont(new java.awt.Font("Dialog", 0, 12));
fet_l.setText("pause . . . ");
addComponent(contentPane, fet_l, 40,67, 140,20);
}
pause routine :
void pause(int msec) {
try
{
Thread T = new Thread();
// ask currently executing Thread to sleep for msec ms
T.sleep(msec);
}
catch(InterruptedException e)
{
System.out.println("Sleep interrupted:"+e);
}
}
|
|
| Back to top |
|
 |
Thomas Weidenfeller Guest
|
Posted: Mon Apr 18, 2005 11:14 am Post subject: Re: Pausing in a GUI |
|
|
Gil wrote:
| Quote: | I'm trying to display multiple frames with a pause of a few seconds
between
the display of each frame. I have the following code, but the swing
components of each frame will not appear before the pause starts. The
components only flash on the screen before the frame disappears and
the next frame appears which is also blank until just before it
appears.
Would anyone know what I might be doing wrong?
|
Since you didn't provide complete code, we can only guess. You probably
block the EDT. See the Top 5 list of questions in the FAQ for details.
You might also want to study the Swing/AWT architecture and painting
model a little bit more in detail. The FAQ provides pointers to the
relevant TSC papers.
/Thomas
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|