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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:47:39+00:00 2026-06-03T03:47:39+00:00

I’m using the following method to display a frame: public static void createImage(final String

  • 0

I’m using the following method to display a frame:

public static void createImage(final String url, final String file, final String filetype) {
        UIUtils.setPreferredLookAndFeel();
        NativeInterface.open();
        SwingUtilities.invokeLater(new Runnable() {

            @SuppressWarnings("deprecation")
            @Override
            public void run() {

                frame = new JFrame();
                WebsiteThumbnailCreator ex = new WebsiteThumbnailCreator(url, file, filetype);

                frame.getContentPane().add(ex, BorderLayout.CENTER);
                frame.setSize(FRAMESIZE);
                frame.setLocationByPlatform(true);
                frame.setVisible(true);
                frame.hide();
            }

        });

        NativeInterface.runEventPump(); 
  }

Then i do some calculation and after that, I want to dispose the frame again:

try {
   ImageIO.write(rendered, filetype, new File(file + "." + filetype));
   frame.dispose();
   logger.trace("Tried to dispose the frame");
} catch (IOException e) {
   logger.fatal(e.getMessage());
} finally {
    logger.debug("Try to dispose the frame");
    frame.dispose();
}

I can see the log messages but however, the VM is still running. I want to also terminate it. What am I doing wrong?

There seems to still be running one non deamon thread, but I can’t see why:

enter image description here

  • 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-03T03:47:40+00:00Added an answer on June 3, 2026 at 3:47 am

    You’re not setting the JFrame’s default close operation and it’s defaulting to JFrame.HIDE_ON_CLOSE.

    Add to your JFrame set up code:

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    

    If your JFrame is your application and you want to exit everything when the JFrame closes, or

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    

    if your JFrame is not the whole application and you want to stop the Swing thread but continue processing.

    For more on this, please check out the JFrame API

    Edit:
    Regarding your comment,

    @HovercraftFullOfEels okay if what you say is right why is my frame disappearing in this code: public static void frameTest() throws InterruptedException { final JFrame jf = new JFrame(“Hello World”); jf.setBounds(100, 100, 400, 400); jf.setVisible(true); Thread.sleep(8000); SwingUtilities.invokeLater(new Runnable() { public void run() { // TODO Auto-generated method stub jf.dispose(); } }); }

    Which I translate to:

    public static void frameTest() throws InterruptedException {
      final JFrame jf = new JFrame("Hello World");
      jf.setBounds(100, 100, 400, 400);
      jf.setVisible(true);
      Thread.sleep(8000);
      SwingUtilities.invokeLater(new Runnable() {
         public void run() {
            jf.dispose();
         }
      });
    }
    

    This only exits if there are no more non-daemon threads left. If you give it a non-daemon thread, this will keep running. For e.g.,

    public static void main(String[] args) {
      new Thread(new Runnable() {
         public void run() {
            for (int i = 0; i < 30; i++) {
               System.out.println("i := " + i);
               try {
                  Thread.sleep(1000);
               } catch (InterruptedException e) {
                  e.printStackTrace();
               }
            }
         }
      }).start();
      try {
         frameTest();
      } catch (InterruptedException e) {
         e.printStackTrace();
      }
    }
    

    Your code will keep running in this example.

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

Sidebar

Related Questions

public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but

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.