Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4560970
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:00:28+00:00 2026-05-21T18:00:28+00:00

I am making a small application, with a JMenuBar, now, I got a menuitem,

  • 0

I am making a small application, with a JMenuBar, now, I got a menuitem, which is a store, which opens a new JFrame. When I click the button, a new JFrame appears, all good. But, when I click the close button of my Store JFrame, I don’t want my main JFrame to close. If I press the store-close-button now, it will close down both the main JFrame, and the Store JFrame, any help on making like, 2 separate close buttons for these 2 JFrames? Code for main JFrame:

    public static void main(String[] args){

    //Create new JFrame
    JFrame frame = new JFrame();
    frame.setTitle("MrStan");
    frame.setSize(200, 200);
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    frame.setJMenuBar(menubar);

    //Set location of JFrame
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    int screenWidth = (int) dim.getWidth();
    int screenHeight = (int) dim.getHeight();
    frame.setLocation(screenWidth / 2 - 200, screenHeight / 2 - 200);

    //Set ContentPane to JPanel
    MrStan panel = new MrStan();
    frame.setContentPane(panel);

    //Make the user not be able to resize
    frame.setResizable(false);

    //Make the JFrame visible
    frame.setVisible(true);

}

My store JFrame:

    public MrStanStore(){   
    JFrame frame2 = new JFrame();
    frame2.setTitle("Store");
    frame2.setSize(300, 200);
    frame2.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

    //Set location of JFrame
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    int screenWidth = (int) dim.getWidth();
    int screenHeight = (int) dim.getHeight();
    frame2.setLocation(screenWidth / 2 - 200, screenHeight / 2 - 200);

    //Make the user not be able to resize
    frame2.setResizable(false);

    //Make the JFrame visible
    frame2.setVisible(true);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T18:00:28+00:00Added an answer on May 21, 2026 at 6:00 pm

    Don’t use 2 JFrames. Generally applications should have a single JFrame and then you use JDialogs for support windows. JDialogs to not support exiting the VM when then are closed so this will not be an issue.

    If you do use a JFrame then you should use DISPOSE_ON_CLOSE. Then when the last frame is closed the VM will exit automatically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a small chat application. I got to the point where one client
I'm making a small web application in Seaside. I have a login component, and
I'm making a small quiz-application in Flash (and ActionScript 3). Decided to use the
I am making a small application with Tkinter. I would like to clean few
I'm making a small application that is supposed to download info from the web
I'd like to test my knowledge in EJB, making an small application. Could you
I'm making a small tool application that user can minimize in the taskbar .
I'm making a small business application and I'm wondering what the best interface would
I am making a small personal application regarding my trade of shares of various
Im making a small python script to upload files on the net. The script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.