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

  • Home
  • SEARCH
  • 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 3227752
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:36:42+00:00 2026-05-17T16:36:42+00:00

When I am using the wait() method in the following code its throwing the

  • 0

When I am using the wait() method in the following code its throwing the following Exeption

Exception in thread "AWT-EventQueue-0" java.lang.IllegalMonitorStateException

The code is as follows:

private void newMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                            
        newFileChooser = new JFileChooser();

        int returnVal = newFileChooser.showSaveDialog(null);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            filename = newFileChooser.getSelectedFile();
            JFrame mainFrame = NetSimApp.getApplication().getMainFrame();
            networktype = new NetType(mainFrame);
            networktype.setLocationRelativeTo(mainFrame);
            NetSimApp.getApplication().show(networktype);
            try {
                this.wait();
            } catch (InterruptedException ex) {
               Logger.getLogger(NetSimView.class.getName()).log(Level.SEVERE, null, ex);
            }
            if (!NetType.validip) {
                statusTextArea.append("File not created:Select Network Type.\n");
            }
            newNodeMenuItem.setEnabled(true);
        } else {
             newNodeMenuItem.setEnabled(false);
            statusTextArea.append("File not created:Access cancelled by user.\n");
        }
    }

Actually I am calling the object of a jDialog class and i want that the dialog object should complete first and then it should notify the above given code. I’ve already specified notify() in that class. Can anyone tell me whats the problem and its solution. -Thanks in advance

  • 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-17T16:36:43+00:00Added an answer on May 17, 2026 at 4:36 pm

    Your wait method needs to be enclosed in a synchronized method or a lock block, with the object being locked on the object you want to wait upon.

    In your case, you should make the method synchronized, which is equivalent to calling lock (this).

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

Sidebar

Related Questions

I am using the following query to select wait times from the table wait_times
I am using the following code. Which is submitting fine with php and it
I have following Java code: import java.io.*; class Global{ public static int a =
I'm running the task using following code, mTimerForImageUpload = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); if
I am Plotting a pixel on the screen from the following code using Assembly
When I wait on a non-signaled Event using the WaitForSingleObject function, I find that
I am doing a media file scan using sendBroadcast. Then I need to wait
For convenience, I am using a helper class that allow to display a wait
Consider the following code :- public class UsingWait1{ public static void main(String... aaa){ CalculateSeries
I'm trying to start a Amazon EC2 cloud machine with [startInstance][2] method using aws-sdk

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.