Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Re-Initialization of FrameView app components??

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re-Initialization of FrameView app components??

    Hi, i have written small program that works with TCP/IP sockets. I am connecting to a server with call to a connect function right after super(app); initComponents(); in the constructor, and i'm catching IOException, that i am throwing in the function for the connection that i have written outside of the constructor. At the Exception handling, in the catch block, i'm creating (with object of the main class) another window with dialog for entering another IP and port with button for reconnecting. Now, after all that pass, and the connection is up, my main window isn't showing up, because, i think, of the error exception that has happened in the first try. The matter is that if the connection is up after first try (when my server application is up and running), all works fine. So my question is: How can i make something like Re-Initialization of the main window, or in other words, how to continue to load the application. I have tried to put initComponents() after try/catch block for the connection but it can't be done that way because the window that is invoked from the catch block is attached to the main frame.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Re-Initialization of FrameView app components??

    Could you post your code? It'd be easier for us to understand what your problem is.

    From reading what it is you had written, I think it might work (not likely, though) if you move the variable declaration outside of the try block
    Frame mainFrame;
    boolean initialized = false;
    try
    {
         // your code in here
         initialized = true;
    }
    catch(Exception e)
    {
         // exception code
    }
    if (!initialized)
    {
         // initialize mainFrame here
    }

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Re: Re-Initialization of FrameView app components??

    Hi, thank you for your replay but i have already solved the problem.
    Only thing that i did was adding this.getFrame().setVisible(true); at the end of the function for the connection, because of the weird reason, when exception happens, my main window dissapeares. Maybe this is not the ultimate solution, but for now it works fine for me.

    Thanks again,
    Salut.

Similar Threads

  1. How can i make the components resizable?
    By ces_31 in forum AWT / Java Swing
    Replies: 4
    Last Post: October 1st, 2009, 11:46 AM
  2. Painting swing components to an arbitrary position?
    By ScummyChimp in forum AWT / Java Swing
    Replies: 1
    Last Post: September 2nd, 2009, 12:06 AM
  3. count components inside a JPanel
    By dewboy3d in forum AWT / Java Swing
    Replies: 1
    Last Post: August 2nd, 2009, 04:17 PM
  4. Change JFrame components problem
    By bruno88 in forum AWT / Java Swing
    Replies: 0
    Last Post: June 30th, 2009, 02:25 PM
  5. Replies: 2
    Last Post: March 6th, 2009, 03:00 PM