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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:16:38+00:00 2026-05-22T17:16:38+00:00

What I was told, which sparked my curiosity on this topic: Java gui classes

  • 0

What I was told, which sparked my curiosity on this topic:

Java gui classes can implement hundreds of Listeners and Callbacks and many books teach you to implement all these interfaces in your gui class. Alternatively, these aspects can be implemented in inner classes, so methods called by that listeners do not get mixed up.

I’d like to know how to do this in ActionScript, which doesn’t have inner classes, but has private classes. But, I don’t think I fully realize what inner classes are about, so I’m merely trying to wrap my head around the situation where I would use them to organize a class’ methods by their usages.

Please show an example of how this would look in ActionScript, if possible, otherwise Java.

  • 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-22T17:16:39+00:00Added an answer on May 22, 2026 at 5:16 pm

    In java it looks like that:

      new JButton().addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              // code that will be performed on any action on this component
          }
      };
    

    here ActionListener – is an interface, and by calling new ActionListener() {/*interfaces method implementations goes here*/}; you’re creating anonymous class (anonymous because it has no name) – implementation of that interface.

    Or you can make inner class like this:

     class MyActionListener implements ActionListener {
       public void actionPerformed(ActionEvent e) {
          // code that will be performed on any action on this component
       }
     };
    

    and then use it like this:

     new JButton().addActionListener(new MyActionListener());
    

    Moreover you can declare your listener as a top-level or static inner class. But using anonymous inner class sometimes is very useful because it allows you to implement your listener almost in the same place where the component which actions your listener is listening to is declared. Obviously it won’t be a good idea if the listeners methods code is very long. Then it would be better to move it into a non-anonymous inner or static nested or top-level class.

    In general, innner classes are non-static classes that somehow resides inside the body of the top-level class. Here you can see examples of them in Java:

    //File TopClass.java
    class TopClass {
        class InnerClass {
        }
        static class StaticNestedClass {
        }
        interface Fooable {
        }   
        public void foo() {
            new Fooable(){}; //anonymous class
            class LocalClass { 
            }
        }
        public static void main(String... args) {
            new TopClass();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been given this simple VB application and library which I'm told can open
I've been told you can interpret Haskell files (which I assume means they will
Someplace I saw a snippet of code which told vi to use soft tabs
while doing some homework in my very strange C++ book, which I've been told
Someone told me to do this in order to keep track of latest people
i was told to write program which generate unique 5 digit number ( for
I've been told that some apps have video streaming which streams initially and when
All pages of my application use the AbsoluteLayout which is deprecated. I was told
I was told there are multiple situations in which initialization list must be used
My boss told me to help in a phone interview with a candidate which

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.