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 9 of 9

Thread: Mutiple JFrames Problems

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Location
    Jamaica
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Mutiple JFrames Problems

    I am writing a program that asks the user for a user name and password. When the correct user name and password is entered a new windows appears. Currently all i do is set the first JFrame visible to false and the new one to true in a separate class[note both classes inherits JFrame]. However, i want to know if instead of making the second class inherit JFrame, if i could just let it inherit the first and what would i need to do to make it look like a new window.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Mutiple JFrames Problems

    what would i need to do to make it look like a new window.
    Do you want to have two windows?
    If you create a class that extends JFrame and that class adds some components and calls setVisible you will have a window displayed.

    If the second class extends the first one and the first one extends JFrame, then you can create a window with it as above.

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Location
    Jamaica
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Mutiple JFrames Problems

    Quote Originally Posted by Norm View Post
    Do you want to have two windows?

    If the second class extends the first one and the first one extends JFrame, then you can create a window with it as above.
    I don't understand what ur saying, but i want to know if instead of creating two windows if i can just use one and get the same effect by using inheritance
    Last edited by mDennis10; September 3rd, 2011 at 08:09 PM.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Mutiple JFrames Problems

    i can just use one and get the same effect
    What are the "effects" you are looking for with only one window?

  5. #5
    Junior Member
    Join Date
    Sep 2011
    Location
    Jamaica
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Mutiple JFrames Problems

    I want continuous effect in my application rather that window poping up effect when i create a new JFrame

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Mutiple JFrames Problems

    Do you mean you want to remove the currently displayed components in the window and replace them with a new set?

  7. #7
    Junior Member
    Join Date
    Sep 2011
    Location
    Jamaica
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Mutiple JFrames Problems

    yes, but when the user logs out the original components and then redisplayed

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Mutiple JFrames Problems

    As the state of your program changes, you should be able to change the components by removing them and adding others.

  9. #9
    Member
    Join Date
    Aug 2011
    Posts
    48
    My Mood
    Fine
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: Mutiple JFrames Problems

    You should use CardLayout to store individual screens as game cards, then show one card at a time.

    immutable objects
    Last edited by ha.minh.nam; December 4th, 2011 at 07:36 PM.

Similar Threads

  1. Duda Con JFrames
    By GuzmanDiaz18 in forum AWT / Java Swing
    Replies: 3
    Last Post: June 2nd, 2011, 03:24 AM
  2. JFrames and JMenuBars
    By rushhour in forum AWT / Java Swing
    Replies: 3
    Last Post: November 4th, 2010, 05:14 PM
  3. JFrames not coming up?
    By scooty199 in forum AWT / Java Swing
    Replies: 13
    Last Post: October 30th, 2010, 02:54 AM
  4. rmi problems
    By deepthought in forum Java SE APIs
    Replies: 7
    Last Post: September 7th, 2010, 07:25 PM
  5. Multiple JFrames
    By Scottj996 in forum AWT / Java Swing
    Replies: 1
    Last Post: April 15th, 2010, 05:24 AM