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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:06:18+00:00 2026-06-12T18:06:18+00:00

I have some code which adds a Java FX WebView to a JFrame. This

  • 0

I have some code which adds a Java FX WebView to a JFrame. This works great. Once the user has visited a specific website, I’m trying to programatically close this JFrame, first by calling Platform.exit() and then frame.dispose(). This works fine as long as I call this method from the same thread that the WebView was started from.

However, this is what I am trying to avoid. Consider the following code (http://pastebin.com/kAjweLi5).
This code tries to shut down the program when the URL changes. However, this results in:

IllegalStateException: Attempt to call defer when toolkit not running
(stacktrace)

Update:
Using my (very limited) debuggning knowledge, I realized that the exit() method seems to successfully run. Image of the stack:

enter image description here

(the error occures when the yellow line is executed)

How can I close the JFrame from another thread/class, without getting the above exception?

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

    From previously (amended) post:

    public void exit()
    {
       Platform.runLater( new Runnable(){@Override public void run(){
          System.err.println( "exit/runLater/run" );
          webEngine.getLoadWorker().cancel();
          Platform.exit();
          SwingUtilities.invokeLater( new Runnable(){ @Override public void run() {
             System.err.println( "exit/invokeLater/run" );
             frame.dispose(); }});
          }});
    }
    

    It’s necessary to shutdown background threads

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

Sidebar

Related Questions

I have this code, which creates an image, and then adds some effects to
I have this JS code which adds some HTML inside a tbody : thestring='<tr><td><input
I have some code which I think has extra release statements. Is the code
I have the following code which adds some arrays to a hashmap but then
I have some code which adds a tooltip to all links. Now, the page
I have some iPhone SDK 4.0 code which initializes an NSOperationQueue and then adds
I have Java application which adds JTextFields @ runtime to JPanel. Basically user clicks
I have some Java code which I'm translating to Scala. The code consists of
Possible Duplicate: Remove handlers on disposing object I have some code which dynamically adds
I have have some code which adds new cells to a table and fills

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.