Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

invokeLater

Thread view: 
Ike - 01 Feb 2007 17:43 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
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.