Can anyone please tell me why my invokeLater in the following code never
displays the JFrame I am trying to get it to display, and shows no
exceptions either? I am certain I must have somethign stupid and wrong here.
Thanks, Ike
public void putupreconnectnotice(boolean on){
if(on){
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
connectionLost();
}
});
}else{
if(waitjframe!=null){
waitjframe.dispose();
}
}
}
private void connectionLost(){
waitjframe = new JFrame("Connection to server lost!");
waitjframe.setSize(310, 75);
waitjframepanel=new JPanel();
waitjframepanel.setPreferredSize(new Dimension(300,60));
waitjframepanel.setBackground(Color.WHITE);
waitjframepanel.add(new JLabel("Attempting to reconnect"));
waitjframe.getContentPane().add(waitjframepanel);
waitjframe.pack();
waitjframe.setVisible(false);
waitjframepanel.grabFocus();
}
Steve W. Jackson - 01 Feb 2007 17:47 GMT
> Can anyone please tell me why my invokeLater in the following code never
> displays the JFrame I am trying to get it to display, and shows no
[quoted text clipped - 27 lines]
> waitjframepanel.grabFocus();
> }
Perhaps it's because your connectionLost method specifically calls
setVisible(false) on the frame?

Signature
Steve W. Jackson
Montgomery, Alabama
Michael Rauscher - 01 Feb 2007 17:54 GMT
Ike schrieb:
> Can anyone please tell me why my invokeLater in the following code never
> displays the JFrame I am trying to get it to display, and shows no
> exceptions either? I am certain I must have somethign stupid and wrong here.
> Thanks, Ike
Apart from the possibility of passing false to putupreconnectnotice, I'd
expect that this
> waitjframe.setVisible(false);
isn't what you really want :)
Bye
Michael
Daniel Pitts - 01 Feb 2007 19:01 GMT
> Can anyone please tell me why my invokeLater in the following code never
> displays the JFrame I am trying to get it to display, and shows no
[quoted text clipped - 27 lines]
> waitjframepanel.grabFocus();
> }
As others have pointed out
you might want to setVisible(true) instead of setVisible(false)
Ike - 01 Feb 2007 20:14 GMT
Yep....that was it....I just couldn;t see it. Thanks so much guys. -Ike
Tom Hawtin - 03 Feb 2007 18:16 GMT
> public void putupreconnectnotice(boolean on){
> if(on){
[quoted text clipped - 9 lines]
> }
> }
Not the problem you were having, but dispose should be run in the EDT as
well as showing the frame.
private volatile boolean notice;
public void setNotice(boolean notice){
this.notice = notice;
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
if (MyClass.this.notice) {
connectionLost();
} else {
if (noticeFrame != null){
noticeFrame.dispose();
}
}
}
});
}
Tom Hawtin