AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pausing in a GUI

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Gil
Guest





PostPosted: Mon Apr 18, 2005 10:52 am    Post subject: Pausing in a GUI Reply with 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?

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





PostPosted: Mon Apr 18, 2005 11:14 am    Post subject: Re: Pausing in a GUI Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.