Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2010
    Posts
    5
    Rep Power
    0

    Post Need help running 2 frames at the same time.

    I'm writing a program where I have to run multiple JFrames at the same time. To make things simpler: The following Frame is dispayed:

    Need help running 2 frames at the same time.-untitled.jpg

    When the wrong user name for player 1 is entered a dialog will display asking if the user wants to create a new acccount. When he answers yes the following frame displays:

    Need help running 2 frames at the same time.-untitled2.jpg

    The previous display then automatically enters the details of the new account in the fields when the create a new account frame's confirm button is pressed.

    The problem is when I run both of the frames the program freezes. How do I run 2 interlinked frames?

    PS: The Create a new account frame object is created inside of the new game frame's class.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Two JFrames should display fine together without having to write special code. The fact that the program freezes tells us that you're doing things wrong, but without code, I venture it will be impossible for us to say exactly what or how.

    Also, your second window should likely be a JDialog, either modal or not depending on your program requirements, and not a JFrame.

    Luck!

  3. #3
    Join Date
    Jun 2010
    Posts
    5
    Rep Power
    0

    Default

    How do I make a fully customized JDialog?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    The process of populating a JDialog with components is no different from that of a JFrame, you simply add components to the JDialog's contentPane, call pack when you're done and setVisible(true) when you're ready to display it. It's construction is a little different though as you should pass into the constructor a reference to the calling JFrame / JDialog / Window as well as the title String and also indicate in the constructor if it will be a modal JDialog or not. The API and tutorials will give you the details.

    Also, you may wish to search this and other forums using JDialog as a search topic to see examples of code that create and display these. For e.g.,

    Is there any standard way to manage multiple JFrames?
    Last edited by Fubarable; 07-03-2010 at 04:26 PM.

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,001
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Fubarable View Post
    The process of populating a JDialog with components is no different from that of a JFrame, you simply add components to the JDialog's contentPane, call pack when you're done and setVisible(true) when you're ready to display it. It's construction is a little different though as you should pass into the constructor a reference to the calling JFrame / JDialog / Window as well as the title String and also indicate in the constructor if it will be a modal JDialog or not. The API and tutorials will give you the details.
    There's also another small difference (and I consider this an anomaly): if the JDialog is resizable it inherits its title bar icon from its parent. If it isn't resizable it doesn't have an icon. Whoeever invented that has been smoking silly sigarets ;-)

    kind regards,

    Jos

Similar Threads

  1. Running thread a second time
    By Fleur in forum New To Java
    Replies: 18
    Last Post: 11-17-2009, 12:57 PM
  2. need info on running thread during a particular time interval alone
    By karthikeyan_raju in forum Threads and Synchronization
    Replies: 2
    Last Post: 10-06-2009, 02:40 AM
  3. Improve the slow running time
    By coolFrenzi in forum Advanced Java
    Replies: 1
    Last Post: 04-12-2009, 12:15 PM
  4. Calculating the Running time
    By JordashTalon in forum New To Java
    Replies: 2
    Last Post: 02-13-2009, 10:32 PM
  5. Replies: 1
    Last Post: 01-12-2009, 08:59 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •