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 8389555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:45:35+00:00 2026-06-09T18:45:35+00:00

This is no doubt a simple question for expert ‘swingers’ but after some research

  • 0

This is no doubt a simple question for expert ‘swingers’ but after some research I’ve not come up with anything.

I have code in this form:

    public static void main(Strings[] args) {
    final JFrame frame = new JFrame("Symbol Formatter");
    final JButton button = new JButton("Begin");
    final JFileChooser filechoose = new JFileChooser();

    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            filechoose.showOpenDialog(frame);
            filename = filechoose.getSelectedFile();

            doSomething(filename);

            button.setEnabled(false);
            frame.setVisible(false); //edit for Andrew Thompson
        }

    });
    JPanel panel = new JPanel();
    panel.add(button);
    frame.add(panel);
    frame.pack();
    frame.setSize(250, 75);
    frame.setLocationByPlatform(true);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setVisible(true);
}

I want to close the swing application once doSomething(filename) is completed. At the moment, the original frame remains where it is and the application only terminates when the frame is closed manually. How can I close once doSomething(filename) has run once.

I’m sure this is a simple question and just requires changing setDefaultCloseOperation however, the Jframe documentation hasn’t helped me much.

Also, is there a way to add a title to the showOpenDialog? So that is has something like “Choose library file” as the title

  • 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-06-09T18:45:37+00:00Added an answer on June 9, 2026 at 6:45 pm

    You could use:

    frame.dispose()

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

Sidebar

Related Questions

I'm not a bash scriptor, so this is no doubt a very simple question.
This is no doubt a very simple question, but unfortunately I have looked around
May be i am not able to express my doubt properly in this question
This is presumable a simple C++ question, but I'm relearning C++ and don't know
Ok, this isn't going to be the best quality question without a doubt. But
This is no doubt a newbish question, but I have looked for an answer
This may sound like a simple question but as am newbie in Webservies and
ORIGINAL QUESTION: (My question applies to Python 3.2+, but I doubt this has changed
My doubt is simple, how can I show an exception using this INotifyDataErrorInfo in
I had this doubt for sometime now, some people say that there's no such

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.