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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:24:34+00:00 2026-06-11T18:24:34+00:00

I am trying to use file chooser in my code, I am getting an

  • 0

I am trying to use file chooser in my code, I am getting an error "Not an enclosing class" in "int returnVal = fc.showOpenDialog(FileChooserDemo.this);". Below is my code. ANy guesses to solve it?

browse_button.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {

     int returnVal = fc.showOpenDialog(FileChooserDemo.this);

      File file = fc.getSelectedFile();

                log.append("Opening: " + file.getAbsolutePath() + "." + "\n");
                String ab=file.getAbsolutePath();
                System.out.println(ab);

}});

I have made the actionlistener in main method.

  • 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-11T18:24:35+00:00Added an answer on June 11, 2026 at 6:24 pm

    Your problem is that you’re making this call in a static method, main(...), and are trying to use FileChooserDemo.this (a reference to the enclosing class) inside of this static method. Well this won’t work because there is no this in the static world. The solution is to do this in non-static code such as a non-static method or the class’s constructor.

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

Sidebar

Related Questions

I am trying to use header file sstream.h Below is my code segment #include
In Spring MVC Hibernate application , when i am trying to use properties file
I'm trying to use a JUMI file (a component for Joomla that allows me
I'm trying to use a settings file to store the user preferences when he/she
I am trying to use the HTML5 file API and jQuery to show the
I'm trying to use a jar file in an android application on the linux
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
All, I'm trying to use the jQuery File Upload Demo: http://blueimp.github.com/jQuery-File-Upload/ My question is
In my XML file I am trying to use a path to a file;
been trying to search the reason for this error for a long time and

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.