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

Thread: Opening a new frame on close.

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Opening a new frame on close.

    I am hoping that there is a way to open a different frame when Xing(pressing the X) out of another. I am aware of setDefaultCloseOperation() but could this open up a different frame? I know if I have a if(frame1.isVisible()) or a if(!frame1.isVisible()) I could do something like what I want, but the thing is sometimes it is supposed to not be visible. I want it so that the user will be able to press the X button at the top left, and have the frame that is supposed to come up, pop up.

    Here is the scenario, I am making a game with a backpack, when you press the backpack button, the frame1 goes away, and backPackFrame pops up. There is a button for the user to press to make frame1 pop up and backPackFrame to go away, but some people will press the X thinking it will close the backPackFrame and make frame1 pop up. It doesn't, it will shut down the whole program.

    Since there is more than frame1 and backPackFrame so I cant use if(frame1.isVisible()) or a if(!frame1.isVisible()) I need to know if I can be able to use something along the lines of setDefaultCloseOperation() to open up a different frame

    Thanks in advance!
    ~Alex


  2. #2
    Junior Member
    Join Date
    Jun 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Opening a new frame on close.

    In the smallest amount of time, I have thought of a way to fix this. Just set setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOS E) so that the user CANNOT hit the X button and can only hit the button I made.

    Sometimes all you need is to write out your situation.

Similar Threads

  1. Help me my IDE is not opening
    By Pms.java in forum Java IDEs
    Replies: 4
    Last Post: August 31st, 2011, 05:11 PM
  2. Opening a file with a java program
    By hafunui in forum Java Theory & Questions
    Replies: 4
    Last Post: March 1st, 2011, 03:52 PM
  3. Replies: 3
    Last Post: February 21st, 2011, 06:25 PM
  4. Opening a File for User
    By aussiemcgr in forum Java Theory & Questions
    Replies: 3
    Last Post: July 29th, 2010, 03:00 AM
  5. opening Telnet Command Session
    By voyager in forum Java Networking
    Replies: 3
    Last Post: June 23rd, 2009, 10:34 AM