How can I get the container of a button after the button is clicked?

I have two components:
public class A extends JPanel implements ActionListener {
    public A() {
    public void actionPerformed(ActionEvent e) {
        String command = e.getActionCommand();
        // here need to know the instance of B to execute it's process()
        // but I can only know the button jb in B via the following code:
        JButton myjb = (JButton)(e.getSource());
public class B extends JPanel {
    public ContainerInfoInput(ActionListener al) {
        JButton jb = new JButton("OK");
        jb.setActionCommand("B.ok");
        jb.addActionListener(al);
    public process() {
public class Main {
    A a = new A();
    B b = new B(a);
}How can I get the instance of B in which the button is clicked?
Thank you

I think it's a defect of the listener mechanism. Under the present circumstance, I must do it like the following:
I must use another class M as a bridge:
class A {
    public A() { }   
    public processA (String info ){}
class B{
    public B(ActionListener al) {       
        JButton jb = new JButton("OK");       
        jb.setActionCommand("B.ok");      
        jb.addActionListener(al);  
   public String processB () {    }
class M implements ActionListener  {
    public M() {
        A a = new A();
        B b = new B(this);
    public void actionPerformed(ActionEvent e) {
        String command = e.getActionCommand();
        if(command.equals("B.ok")) {
            String information =b.processB();
            a.processA(information);
}Why not just use A to listen B and obtain instance of B through the ActionEvent?
Anyone know a solution about it?

Similar Messages

  • How can I get PSE12 Trial Editor to start after icon is clicked, when Organizer runs ok?

    How can I get PSE12-Trial Editor to start, after Editor icon is clicked, although Organizer runs? The wait or loading icon or message runs for about 60 seconds, then disappears and actual load and run of Editor space never occurs.
    Can you help?

    It must be on your iPad somewhere.  Pull down on the center of your iPad screen to bring up spotlight search at the top.  Enter Starz in the search box to see if the app is located below it.  If it is, and is "hiding" inside a folder, the name of the folder it is in will appear to the far right.

  • How can I get all tracks from an album into the album in my library?

    When importing the albums from a folder, the tracks for some of the albums were split up.  How can I get them in one?

    Hello JudyD276
    The article below will give the steps to get the songs grouped together for you.
    Why aren't songs with the same album art grouped together?
    http://support.apple.com/kb/TS1468
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • My friend synced a video to my ipod but it erased all my data on my ipod,but i cant figure out how to load my old libray back without deleting the movie. my friend cant tell me the password. How can I get my old library back without deleting the movie?

    My friend synced a video to my ipod but it earased all my data on my ipod,but I can't figure out how to load my old library back without deleting the movie. My friend shares a family account so she can't tell me the password. How can i get my old library back without deleting the movie?

    Linnwarner wrote:
    She does have the right because she bought the movie.
    Not true at all.
    You only buy the right to your own personal use.
    You do NOT have the right to distribute to others.
    This is illegal.  There is no doubt about it

  • How can I get my books that I download from the Library that are WMA files into my I tunes so I can listen to them

    How can I get my books that I download from the Library that are WMA files into my I tunes so I can listen to them. They have a ton of books but I can only listen to them from my windows media player and I wouldlove to download to my I pod but I have tried everything I can think of it they won't go over.  Someone said all I had to do was copy them over and they would convert but I can't even get them to copy.  Thanks.

    Well it started happening AGAIN with my 2nd IPod. No matter what I did, it Itunes would NOT restore it!
    I finally installed Itunes on my hubby's PC at work and managed to get it restored there.
    Apparently, there must be some sort of compatibility issue with the windows version of Itunes and some other piece of software on my pc.
    And one more important thing! I had to follow the instructions in the other thread that talks about how to correctly uninstall itunes and quicktime, in order to completely eliminate ALL traces of my "first" ipod's existence so it wouldn't demand that I restore it.
    I think the software got "confused" and thought when I connected my 2nd ipod, that it was the 1st and that it still needed to be restored.
    Basically, this is just POORLY written and POORLY tested software!

  • How can I get a file to copy all of the files in a directory except itself and the source of the copy function will be the directory the final program is in?

    How can I get a file to copy all of the files in a directory except itself and the source of the copy function will be the directory the final program is in? This application must be in Lab View 8.

    you mean something like this (see below)?
    Now you may have to implement code to check if the destination folder exists and to create it, etc.  But if you use the Front Panel Control to select the destination folder, it should be okay.
    Not the best implementation, mind you but you'll get the idea..
    Message Edited by JoeLabView on 04-18-2007 03:43 PM
    Attachments:
    copy folder contents.PNG ‏10 KB

  • HT1338 How can I get my photo to work again? the app will not open on my desk top any more. I can not dave my photo on my desk top

    How can I get my photo to work again? the app will not open on my desk top any more. I can not dave my photo on my desk top

    Hello, Cubby21. 
    Thank you for using Apple Support Communities.
    Here are the best resources for troubleshooting issues with Message.
    iOS: Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/ts4268
    iOS: Troubleshooting Messages
    http://support.apple.com/kb/TS2755
    Cheers,
    Jason H.

  • How can I get a list of active savepoints for the current session?

    Hi,
    In Oracle Applications, we are getting the following error while performing ROLLBACK to a Savepoint.
    "Unexpected Error: ORA-01086: savepoint 'PTNR_BULK_CALC_TAX_PVT' never establishe d ORA-06510: PL/SQL: unhandled user-defined exception"
    So how can I get a list of active savepoints for the current session?
    Could you please also let me know if there is any better way to debug this issue.
    Appreciate any quick response as the issue is very critical.
    Thanks,
    Soma

    user776523 wrote:
    Hi,
    In Oracle Applications, we are getting the following error while performing ROLLBACK to a Savepoint.
    "Unexpected Error: ORA-01086: savepoint 'PTNR_BULK_CALC_TAX_PVT' never establishe d ORA-06510: PL/SQL: unhandled user-defined exception"It sounds like there's an execution path in the code where the SAVEPOINT is never issued.
    There is no way to get a list of active savepoints. Is this your code or a "canned" procedure? If it is your code you can go through the code looking for answers, possibly tracing execution using DBMS_OUTPUT.PUT_LINE or writing messages to a log table. If its a "canned" procedure you may need to open an SR with Oracle

  • When I try to activate my cs 3 premium production, I get a message saying NO CONNECTION. Everything is in order though. How can I get an activatioon number other then trough the web??

    When I try to activate my cs 3 premium production, I get a message saying NO CONNECTION. Everything is in order though. How can I get an activatioon number other then trough the web??

    Sign in, activation, or connection errors | CS5.5 and later, Acrobat DC

  • When printing two-sided from my Mac on landscape A4 with 2 columns, how can I get my HP Photosmart 6520 to print the same way up?

    When printing two-sided from my Mac on landscape A4 with 2 columns, how can I get my HP Photosmart 6520 to print the same way up?

    Or, it is set the other way around (which makes more sense). Even though you are in Landscape mode, it is binding on the Long Side of the paper. Since you are in Landscape, you would want it to bind on the short side.
    Think of the Binding like a Book. How would you flip the finished pages to read the “book.” Where it would be bound in the imaginary book is how you want it to print.

  • My Mountain Lion app failed while downloading, and now I can't download it without repaying for it.  How can I get my access code to work/download the app?

    My Mountain Lion app failed while downloading, and now I can't download it without repaying for it.  How can I get my access code to work/download the app?

    Welcome to Apple Support Communities
    Open App Store, select Account in Quick Links and press Show hidden purchases. If OS X isn't there, http://www.apple.com/support/mac/app-store/contact

  • How can i get my keyboard to be recognized by the imac?

    how can i get my keyboard to be recognized by the desktop imac?

    Hello emanson805,
    Thanks for using Apple Support Communities.
    If you need to set up your Apple Wireless Keyboard with an iMac, then please follow the directions below.  Please note that if the keyboard was previously paired with another device, you will need to unpair it before being able to pair with your iMac.
    Bluetooth: How to set up your Apple Wireless Keyboard - Apple Support
    Have a good one,
    Alex H.

  • How can I get my iPhone to show up on the panel to the right iTunes? I keep connecting it but it does not work.

    How can I get my iPhone to show up on the panel to the right iTunes? I keep connecting it but it does not work.

    http://support.apple.com/kb/TS1538

  • How can I get my Mac to connect faster to the Internet? My wifi connection is fine....don't know why Safari and other web browsers are so slow.

    How can I get my Mac to connect faster to the Internet? My wifi connection is fine....don't know why Safari and other web browsers are so slow.

    If possible, connect to your router with Ethernet and turn off Wi-Fi. Any difference?

  • How can I get google groups mail to appear in the Mail application on my iPhone 5?

    How can I get google groups mail to appear in the Mail application on my iPhone 5?

    Try to use the SearchReset extension to reset some preferences to the default values.
    *https://addons.mozilla.org/firefox/addon/searchreset/
    Note that the SearchReset extension only runs once and then uninstalls automatically, so it won't show on the "Firefox > Add-ons" page (about:addons).
    If you do not keep changes after a restart then see:
    *http://kb.mozillazine.org/Preferences_not_saved

  • How can I get a small window to open when a link is clicked (AS2)

    Hi i,m developing a HTML site and used one animated flash button(AS2) I want a small sized window to open when a user clicks on a button.
    The window will contain information that i want to display.It dosnt require a normal 800x600 window to open. I just want a 1/4 size of 800x600 etc. Is this possible and if so how.
    I havnt done this before
    Thanks
    Manoj

    HELLO NED,
    I WAS RECEIVING MANY MAILS FROM YOU, BUT I DON'T UNDERSTAND WHY DOESN'T RELATED WITH MY PETITION, I SEND
    TO YOU AGAIN MY QUESTION, AND IF YOU CAN HELP ME I APPRECIATED VERY MUCH LET ME KNOW.
    THIS IS MY QUESTION....."ABOUT DATAGRID AS3
    Hello Ned, I appreciate very much your soon answer, I believe you have understand me, but how can I do that? could you give some help? This is part of the code and this is the function that I use
    var url: String = "xmls/rests.xml";
    var req:URLRequest = new URLRequest(url);
    var myLoader:URLLoader = new URLLoader();
    myLoader.addEventListener(Event.COMPLETE, completeHandler);
    myLoader.load(req);
    function completHandler(event:Event):void {
           var myLoader:URLLoader = event.currentTarget as URLLoader;
           var xmlDP:XML = new XML (myLoader.data);
           XML.ignoreWhitespace = true;
           dp = new DataProvider(xmlDP);
           dp = sortOn("name", Array.CASEINSENSITIVE);
           dDg.dataProvider = dp;
           aDg.addEventListener(Event.CHANGE, changeHandler);
           function changeHandler(event:Event): void {
                var thisItem:Object = eve.target.selectedItem;
                descripTa.text = thisItem.description;
                aUI.source = (thisItem.image);
                preloader_mc.visible = true;
    My intention is that when a button from a main (swf) loads the swf it displayed the first selected item with a image (UILoader) and the description (TextArea)
    Thanks in advance Ned
    Joselyn             .................."
    THANKS AGAIN NED
    REGARDS
    JOSELYN
    Date: Thu, 13 Oct 2011 07:49:02 -0600
    From: [email protected]
    To: [email protected]
    Subject: How can I get a small window to open when a link is clicked (AS2)
    Re: How can I get a small window to open when a link is clicked (AS2) created by Ned Murphy in Flash Pro - General - View the full discussion
    Look at the Methods section and choose whichever suits your needs, the first one listed does not.
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/3969302#3969302
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/3969302#3969302. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Flash Pro - General by email or at Adobe Forums
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

Maybe you are looking for