Add Listener to Unknown Number of JMenuItems

How can I add an ActionListener to each JMenuItem by cycling through an unknown number of menu items?
I have a program that prompts the user for a database, then creates a JMenu of table names based on whatever database the user selects.
This means that I don't know the table names or number of tables that will be added to the JMenu.
I need to add an ActionListener to EACH JMenuItem. The problem is that I am only able to select one table from the menu. Subsequent menu clicks (on different table names) have no affect on the output.
Here is an excerpt of my code:
ResultSet rs = md.getTables(null, null, null, types);
while (rs.next()) {
tables.add(rs.getString("table_name"));
for (Iterator i = tables.iterator(); i.hasNext(); )
String table = (String) i.next();
JMenuItem mi = new JMenuItem(table);
j1.add(mi);
mi.addActionListener(this);
[END CODE]
Thanks for any help you can give!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

I got it. It turns out that I WAS setting the listeners correctly. My additonal output was "hidden" in the window. I found it by pure luck when I expanded the window size.
I added a line to remove all components from the JPanel before adding a new one and this "refresh" worked.
Thanks fot the help anyway! It is greatly appreciated.

Similar Messages

  • Why when I create contact on my iphone does iCloud add a 2nd unknown number?

    I've had a few cases where I've added a new contact to my iphone and when I save it, iCloud adds in a second number that I've never seen before.  My contact now has 2 numbers; one linked to my iphone and the other linked to my icloud though I've never seen that icloud number nor input it.  Any ideas why and how I can stop this from happening?

    its not possible to restore to a backup from a newer IOS

  • Showing dynamic and unknown number of images in SSRS report

    I am using SSRS 2008.  I need to display an unknown number of unspecified images on the report.
    Basically I have a webpage, where the user selects a specific ID (ex. 24) from a dropdown and then click "View Report".
    The report should then display any images, associated with that ID.  The only thing I know about the images, is the path to where the images are stored.  The path is kept in a database, so I should be able to retrieve the path ok.
    But then how do i get the report to display the images, when I do not know the name or number of images?
    Please help.

    Hi dukie4lif,
    According to your description, you have a report to display images selected by users. Now your issue is, the users select a specific ID to get images, but you only have the path of images stored in your database. Is my understanding correct?
    For your requirement, if the users want to get images by selecting a specific ID, this ID must be stored in database and associated with the path of those images. Otherwise the database can never query any records with this ID if it doesn’t have any ID stored.
    Now we need to go to your database, create one more table or add one more column in the table which have your path stored to store those IDs, and let them associated with those path. Use a parameter in this report for users selecting IDs. Then your goal will
    be achieved.
    Reference:
    Report Parameters (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou (Pactera)

  • How do i dial international numbers... I get unknown number

    I got a tmobile 8220 that I unlocked so that I can use in Chile vacation. I try to dial a number and it goes back to the placed calls menu and it says My number Unknown number. I am not sure if that is the real error or it just doesn´t know it´s own number. One time the phone tried to add my US area code to the number. So I was wondering if this is a phoen issue or if it´s a cell phone company issue. The number is 8 digits. x-xxx-xxxx (first x is the region code)

    Good to know that you've resolved the issue by yourself. Please resolve the threat by accepting the solution button.
    tanzim                                                                                  
    If your query is resolved then please click on “Accept as Solution”
    Click on the LIKE on the bottom right if the post deserves credit

  • General ETL question - ETL from unknown number of tables ?

    AFAIK, ETL integrates data from a fixed number of sources/tables. Is it possible that ETL can integrate data from an unknown number of tables which might be added in the future, given that these tables might be of different types (customer, shipping, employee,
    accounting etc.) ? Are there any solutions in SSIS which handle these kinds of scenarios ?
    EDIT -
    Let A,B,C be tables. We can have the following ETL scenarios - A + B + C = 1 row or A + B + C = 3 rows
    I have the first one. Later, we can add tables D,E,F,G...etc all of which might be different from each other in terms of the data they contain.

    AFAIK, ETL integrates data from a fixed number of sources/tables. Is it possible that ETL can integrate data from an unknown number of tables which might be added in the future, given that these tables might be of different types (customer, shipping, employee,
    accounting etc.) ? Are there any solutions in SSIS which handle these kinds of scenarios ?
    EDIT -
    Let A,B,C be tables. We can have the following ETL scenarios - A + B + C = 1 row or A + B + C = 3 rows
    I have the first one. Later, we can add tables D,E,F,G...etc all of which might be different from each other in terms of the data they contain.
    Another Suggestion could be, which might not satisfy your reqt fully but would help you as for me once a new source comes in you need to study it fully before population the new source could be excel .txt sql oracle etc, so it goes like below
    a) Use a Master Child package configuration, so int this case your MASTER package calls table load for your table A B and c.
    b) Once a new load has to be added you would need to design a new package and add it to the solution.
    c) The master package would not need to be changed the trick here is:
    1. Use a foreach loop in the Master packge, this for each loop is driven from a table in DB, which has the deatils around the Desttable load; so lets say today it has values like:
    DestTable LoadedFrom
    TableD A
    TableD B
    TableD C
    Now once new tables have to added just add an entry to this table and the master package would need not be changed only a new package and table entry has to done
    Abhinav http://bishtabhinav.wordpress.com/
    Thanks. It seems that you are talking about something that can me merged or union-ed. A,B,C can be different types - customer, shipping, accounting info etc. I need to join them based on different criteria. Perhaps a
    table can store the joining criteria. Also, I need to select only some columns of each table added. So, I will need a table to store which columns are to be selected for a particular table. 
    I am not sure if your suggestion would apply here.

  • Blackberry z10 unknown number settings

    My blackberry z10 unknown number settings pls
    Subject Title edited to reflect new topic.

    Hi and Welcome to the Community!
    Please add details, from those few words, I cannot understand what your request or issue is. Please clarify.
    Let us know.

  • I get nothing but error messages, -"Your IMAP server wants to alert you to the following: 113 that mail is not available" or 364? there are hundreds stacked up.You must give answers to how to fix these when we do "search" add the error code number

    I get nothing but error messages, -
    "Your IMAP server wants to alert you to the following: 113 that mail is not available"  or  the same with:  364? 
    Now there are hundreds stacked up on my desktop.
    I cannot find the answer anywhere. You need to  give answers to how to fix these errors because when I  "search" "error code" or the number there is NOTHING. NOTHING!  Yet you give us these stupid error codes
    then you do not give us ANYTHING on how to fix these. These error codes make me so mad it makes me hate outlook, and hate the developers and hate microsoft.  How in the world can you give us ERROR codes without the explanation of what
    to do or how to fix it. You need to  add each  error code number in your "search" then explain what it is and how to fix it.  I am not a tech. I am a lawyer. I have googled the entire string of error code and nothing is clear.
    So, for the last several years, I get these error codes. Also, there is another error code that won't go away--it is the password error code that asks if I want to store the password. Yes, so I say YES. but it pops back. I am sick of this. This is the reason
    I hate Microsoft and I love google. #1 they respond to error, #2 them try to fix them you do not. I paid the full price to buy the OUtlook 2010, almost $500 just to get outlook, and all I got was error codes. I could not even open it because all I would get
    was that error codes and NO ONE knew how to fix them. WHAT IS YOUR PROBLEM that you cannot fix the stupid error codes that you imbed? PLEASE HELP

    Hi,
    I understand how frustrated you are when facing such an issue, maybe I can provide some suggestions on the problem.
    Based on the description, you should be using an IMAP account setup in Outlook. As for the error message, usually it's caused by a corrupted message on the Server. I suggest you logon the Webmail site, check if sending/receiving emails works well.
    If you find any unusual emails that cannot be read or sent, try deleting them to try again.
    I also suggest you create a new profile to setup the IMAP account:
    http://support.microsoft.com/kb/829918/en-us
    Contact your Email Service Provider to get the correct and latest account settings, since you have been using Outlook for years, some settings may have been changed while you haven't been informed.
    For the steps to setup an account in Outlook 2010, please refer to:
    http://office.microsoft.com/en-001/outlook-help/add-or-remove-an-email-account-HA010354414.aspx
    I hope this helps.
    Regards,
    Melon Chen
    TechNet Community Support

  • I want to add LOV of Contract Number in quality plan.

    need helping query to add LOV of Contract Number in quality plan which is dependent on invoice number

    FYI - the OP has failed miserably to provide even enough information for us to recommend the proper forum.
    Is it:
    {forum:id=82}
    {forum:id=83}
    {forum:id=210}
    {forum:id=137}
    or something else?

  • How do I use a button to add "1" to a number?

    I'm sure this is so simple that I'm going to be smacking my forehead when someone gives me the answer but for the life of me, I can't figure out how to do this.
    I'm making a simple pdf that lists ticket prices for an event. I want the button to add one to the number of tickets ordered every time it's clicked. I need the starting value to be "0" tickets. How do I do this?

    Hi,
    Use a variable to strore the value. In the click event of the button increment the value. In the click event of the button, you can put the following code.
    var count +=1;
    Thanks,
    Bibhu.

  • Is there a way to make a number of cells add to a certain number. I need 5 or 6 cells to add to 1700. If one of the cells becomes 0, I need the other cells to change so the bottom number stays at 1700.

    is there a way to make a number of cells add to a certain number. I need 5 or 6 cells to add to 1700. If one of the cells becomes 0, I need the other cells to change so the bottom number stays at 1700.

    Okay then. If your seven numbers are in column B then the formula next to each number in column C would be
    =IF(B=0,0,1700/COUNTIF(B,">0"))
    This assumes all non-zero numbers are positive numbers. The sum will be 1700.

  • Deploying simple SharePoint 2013 feature causing error: "Error occurred in deployment step 'Add Solution': An unknown exception occurred while executing a sandboxed code solution request in the worker process."

    When trying to deploy a sandboxed solution containing only a feature with a simple associated event receiver from VS 2013, I'm getting the following error:
    Error occurred in deployment step 'Add Solution': An unknown exception occurred while executing a sandboxed code solution request in the worker process.\r\n|0
    I'm working in Visual Studio 2013, deploying to SharePoint 2013.
    The SharePoint project is very basic. I've only added a feature and an associated event receiver. It works without the event receiver. Then after I simply add the event receiver I get the error.
    I've tried deploying directly from VS 2013 as well as publishing to a .WSP and uploading via web interface. Same error reported using both methods. I'm doing this using an Administrator account that I've confirmed is a site collection administrator.
    Additionally, I've found that if I change Sandboxed Solution to False, deploy it, retract it, then change Sandboxed Solution back to True, then I can successfully deploy it. But this doesn't seem to be a permanent solution as the error will resurface a day
    or two later...

    Hi Steve,
    Are you running your SharePoint 2013 on domain controller? 
    http://www.learningsharepoint.com/2013/08/09/sharepoint-2013-error-an-unknown-exception-occurred-while-executing-a-sandboxed-code-solution-request-in-the-worker-process-rn0/
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/b7408608-c21b-45d9-bc16-e6afff510cd2/installed-sharepoint-2013-foundation-on-window-2010-server-issues-activating-sandbox-solutions?forum=sharepointadmin
    My Blog- http://www.sharepoint-journey.com|
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful

  • Uploading a text file with unknown number of  texts

    Hi ,
    i have a flat file with around  10,000 record's.
    each material number  followed by  different  lengths & unknown number of text's separated by delimiter '$',
    that need to be saved using save_text function module.
    the file is as follows, 
    record 1 :     material1$text1$text2$text3
    record 2 :     material2$text1$text2$text3$text4$text5$text6$.....
    record 3 :     material3$text1$text2$text3$text4$text5
    record 4:      material3$text1
    - - - - - - - - - - - -  so on ....
    i created the following  structure ,  to split and save each text separated by '$'  , to save in TLINE  of save_text function module.
    types : begin of ty_file,
                  matnr type mara-matnr,
                  text1 type string,
                  text2 type string,
                  text3 type string,
                  text4 type string,
                  text20 type string,
               end of ty_file.
    i have uploaded the file and saved in table  it_file type ty_file.
    loop it_file into wa_file.
       split wa_file at '$' in to matnr text1 text2 text3 text4 ....... so on.
    endloop.
    please, suggest me an alternate way to reduce the code, instead of creating a structure like above, so that each splitted text
    stores in a single variable and is passed to TLINE of corresponding material, in save_text function module
    thanks
    viki

    Hi,
    The flat file contains , material No. followed by it's text , each text sepearted by '$' symbol.
    For each material  i have to get all lines of text, and passed to tables paramter of save_text.
    The Number of text' for each material is varying.
    Please kindly suggest me , how many variables i need to create to hold each splitted text and store it in Tline
    I wrote the below program assuming that the material number has  maximum of 20 texts, it's working fine. But, what if the number of texts exceeds 20.
    file :
    4907507$ Druckrolle$ Durchmesser: 218 mm$ Länge: 750 mm$ Rollenwerkstoff: 1.4301/1.4541$ Oberfläche: gummiert$ Stärke Gummierung: 10 mm$ Näscher    E 71224$$$$$$$$$$$$$$                              
    1149598$ Tragrolle$ mit Stützringen$ Norm: ähnlich DIN 22112$ Durchmesser: 89 mm$ Mantellänge: 800 mm$ Form der Achsenden: A2$ Achsdurchmesser: 25 mm$ Achsanflachung: SW 18$ Einlegelänge: 808 mm$ Achslänge: 834 mm$ Lagerbezeichnung: 6305$ Anzahl Stützringe Form A: 6$ Anzahl Stützringe Form B: 4$ Anordnung links: 4$ Anordnung mittig: 6$ Anordnung rechts: 4$ Qualität Stützringe: N$ Durchmesser Stützringe: 159 mm$ Anzahl Zwischenhülsen: 7$ Anzahl Schlussscheiben: 2$ Erbö   3111.800.05.68                                                                      
    file upload
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          static    = 'X'
        CHANGING
          file_name = p_infile.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME            = gd_file
          FILETYPE            = 'ASC'
         HAS_FIELD_SEPARATOR = 'X'
         HAS_FIELD_SEPARATOR = '$'
        TABLES
          DATA_TAB            = It_data.
      loop at it_data into wa_data.
        split wa_data-line at seperator into matnr_txt text1 text2 text3 text4 text5
                                                   text6 text7 text8 text9 text10 text11
                                                   text11 text12 text13 text14 text15
                                                   text16 text17 text18 text19 text20.
        move matnr_txt to wa_material-matnr.
        move text1 to wa_material-text1.
        move text2 to wa_material-text2.
        move text20 to wa_material-text20.
        append wa_material to it_material.
        clear wa_material.
      endloop.
      loop at it_material into wa_material.
        WA_LINE-TDFORMAT = '*'.
        WA_line-TDLINE = wa_material-text1.
        APPEND WA_LINE TO IT_LINE.
        WA_LINE-TDFORMAT = '*'.
        WA_line-TDLINE = wa_material-text2.
        APPEND WA_LINE TO IT_LINE.
        WA_LINE-TDFORMAT = '*'.
        WA_line-TDLINE = wa_material-text20.
        APPEND WA_LINE TO IT_LINE.
        G_THEAD-TDNAME   = wa_material-matnr. " material number
        G_THEAD-TDID     = pa_id.                           "  'GRUN',
        G_THEAD-TDSPRAS  = pa_langu.                "  EN
        G_THEAD-TDOBJECT = pa_obj.                   "  MATERIAL
        CALL FUNCTION 'SAVE_TEXT'
          EXPORTING
            CLIENT                           = SY-MANDT
            HEADER                        = G_THEAD
            SAVEMODE_DIRECT     = 'X'
          TABLES
            LINES           = IT_LINE
          clear : wa_line, g_matnr.
          refresh it_line.
      endloop.
    Edited by: jvsvijay on Jul 28, 2011 12:51 PM
    Edited by: jvsvijay on Jul 28, 2011 12:53 PM
    Edited by: jvsvijay on Jul 28, 2011 12:55 PM

  • How can i add more a phone number in phone 4s

    Hi i'm new for IOS, i have got iphone 4s in my hand. i try to synchronize my contact list to iphone, it's work. but i would like to know how can i add more a phone number into a person in the list. default as show 1.mobile and 2.iphone
    Thanks

    If you have completed the info for a contact there will be additional spaces for more phone numbers. If you have not added a number yet, simply tap the word to the left of the blank phone number space to change the category.
    Stedman

  • Calls from cucm to CME not working-unknown number

    hi all
    we have cucm 9.1 and gateway 2911 on the side A and on the side B we have uc540 , we have configured tunnels between 2911 and uc540, calls from cucm SideA to uc540 Side B is ok and working fine. now we have one 9951 phone which gets ip from uc540 (side B) and tftp is our cucm IP.9951 phone is registered in cucm and calls from cucm to that 9951 phones are working fine. now problem is call is one sided between uc 540 local extension and ip phone 9951.
    9951 which is registered on cucm can call uc 540 user  but spa 504 phone which is registered on uc540 cant call to cisco 9951 phone gets error "unknown number"
    i am attaching debug voice ccapi inout with this
    kidnly help me to solve the issue ASAP

    here is show voice register all.i am surprised to see dial peer 20002 but there is no dial peer like that i dont know where its getting this dial peer 20002.extension 2002 is registered with my call manager.
    Router#sh voice register all
    VOICE REGISTER GLOBAL
    =====================
    CONFIG [Version=8.6]
    ========================
      Version 8.6
      Mode is srst
      Max-pool is 0
      Max-dn is 0
      Outbound-proxy is enabled and will use global configured value
      Security Policy: DEVICE-DEFAULT
      Forced Authorization Code Refer is enabled
      timeout interdigit 0
      network-locale[0] US    (This is the default network locale for this box)
      network-locale[1] US
      network-locale[2] US
      network-locale[3] US
      network-locale[4] US
      user-locale[0] US    (This is the default user locale for this box)
      user-locale[1] US
      user-locale[2] US
      user-locale[3] US
      user-locale[4] US   Active registrations  : 0
      Total SIP phones registered: 0
      Total Registration Statistics
        Registration requests  : 0
        Registration success   : 0
        Registration failed    : 0
        unRegister requests    : 0
        unRegister success     : 0
        unRegister failed      : 0
        Attempts to register
               after last unregister : 0
        Last register request time   :
        Last unregister request time :
        Register success time        :
        Unregister success time      :
    VOICE REGISTER DN
    =================
    VOICE REGISTER POOL
    ===================
    Router#

  • Cannot add data to unknown document?

    Hi there,
    There are several computers working on a server and two other employees were working on the same indesign document at the same time, causing both of them to suddenly crash and then the file became corrupted. When I try and open the document I get the error message 'cannot add data to unknown document'. I still get the same message even when trying to open the file from my desktop. I am using CS5.5 and am on an imac....
    I have tried to find a solution to this in the threads, but so far no luck! Have also tried to call Adobe but they were no help . Any assistance would be greatly appreciated.
    Thanks
    E.Coe

    First off, two people shouldn't have the ability to work on the same file at the same time. That was a bug in the initial release of CS5 or CS5.5 (not sure which) but it was fixed in the first patch. If you haven't updated to 7.5.3 you need to do that to prevent future problems and take advantage of other bug fixes.
    As far as your file, it doesn't sound all that hopeful. Try opening as a copy. If that doesn't work you may have to rebuild, or if more cost effective, use the Markzware recovery service: Bad InDesign or Quark File Recovery Submission Form

Maybe you are looking for

  • Unable to communicate with "ImporterProcessServer"

    Hi there, I searched the forum, but only found one entry, which didn't help. I re-installed Premiere CS4 due to a OS crash. Before that, everything worked smoothly, but now I get an error message saying: unable to communicate with the ImporterProcess

  • Photoshop CS6 for windows will not install.

    I have already copied the lesson files to my hard drive as the book instructs, however there is no autorun screen, or even a shortcut/icon that says Adobe Photoshop, the same applies for Adobe Bridge. What am I doing wrong? I need this for a college

  • Error in Process flow running in SQL owb_run_own.wb_rt_api_exec.run_task

    Hi all We are having issue with owb_run_own.wb_rt_api_exec.run_task using Sql Plus When i try to run through Warehouse Builder Process flow ran Successfully When i try to run through SQL Plus using owb_run_own.wb_rt_api_exec.run_task We are getting e

  • How to convert a String to Date format?

    the user enter a date in string format and the date is save in the database. The problem i am facing is i want to change from String to Date format. Here is my codes:         public boolean insertData() throws Exception {         boolean validFlag =

  • Save data from rt target to host windows pc

    I have a VI created in Windows which I deployed on the RT target and I need to acquire the data from one of the module and store that data in my host windos pc where I am running the VI I am getting an Erro:7 while doing this  I have attached my code