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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:45:47+00:00 2026-05-27T13:45:47+00:00

In my dialog box i have a button.In it’s action listener method what does

  • 0

In my dialog box i have a button.In it’s action listener method what does this refer to ? Is it the reference of the button or the reference of the JDialog ? What i have noticed is that it is the reference of JDialog because when in my IDE i press this. all other components and the methods of containers like dispose come up. If it is so,how it is the reference of JDialog ? It should be of JButton.

jButton5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton5ActionPerformed(evt);
        }
    });

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    boolean rB_1 = jRadioButton1.isSelected();
    boolean rB_2 = jRadioButton2.isSelected(); 
    boolean rB_4 = jRadioButton4.isSelected();

    if(rB_2) 
        new class_design().changeStatusOfMessageDisplayMode(true);

    this.dispose(); // <-------- this one   
}

The above code is called when a button named done is clicked from jdialog

  • 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-27T13:45:47+00:00Added an answer on May 27, 2026 at 1:45 pm

    It’s a reference to the object of the class that implements the ActionListener interface you to addActionListener.

    If you implemented a “standalone” class for that, it’ll be an instance of that class. If you passed in an anonymous class, then it’s a reference to an instance of that anonymous class.

    If the action listener is the JDialog itself, then this refers to the JDialog object.

    In your case, you’re using an anonymous class. So inside actionPerformed, this refers to an instance of that class. But, notice that you’re calling a function that is not defined in that anonymous class. That’s where the “magic” happens: inner classes have a reference to the enclosing class.

    jButton5ActionPerformed(evt);
    

    is equivalent to:

    myenclosingobject.jButton5ActionPerformed(evt);
    

    So inside jButton5ActionPerformed, this refers to an object of the enclosing class, the one that created that anonymous class instance.

    This is explained in the JLS Inner classes and Enclosing instances:

    An instance i of a direct inner class C of a class O is associated with an instance of O, known as the immediately enclosing instance of i. The immediately enclosing instance of an object, if any, is determined when the object is created (§15.9.2).

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

Sidebar

Related Questions

I have a datagrid column with a button that opens a modal dialog box
I have a dialog box that appears when the user clicks a macro button.
I'have a dialog box in JQuery that have two buttons. When the button Upload
I have a simple Jquery dialog box, that dialog contains a button which sends
I have a button that pops up with a dialog box on click. I
I have a dialog box that allows users to set hotkeys for use in
I have a dialog box with controls that is popped up and when a
i have a dialog box that opens on pageload for a site. script type=text/javascript>
I have a v simple dialog box that I would like to display as
I have a problem with the jquery-ui dialog box . The problem is that

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.