How to handle dynamic JMenuItem's actionListener??

I want to implement a function like "Recent File" in "File" menu.
But I don't know how to handle their actionListener?
for (int i=0; i<count; i++)
JMenuItem miNode = new JMenuItem(fileName);
mnuFile.add(miNode);
miNode.addActionListener(...) ///// ----- ????????
}

for (int i = 0; i < count; i++) {
    final String fileName = ... // the i-th file name
    JMenuItem miNode = new JMenuItem(fileName);
    mnuFile.add(miNode);
    miNode.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // do whatever you want using "fileName" variable
            System.out.println("You have selected the '" + fileName + "' file.");
}Alternatively you can create one ActionListener and add it to all menu items. When event is fired you can use ActionEvent.getActionCommand() - it will return the text of the JMenuItem (the file name on your case) that caused the event provided that you set only JMenuItem text (as you do in your example).

Similar Messages

  • How to Handle dynamic views in mm01 transaction

    Hi ,
           Can any body say me how to handle Dynamic views in MM01 tcode. Since every time new view has to be selected, how can we manage this through our program.
    Regards,

    Hi Nilesh,
    Views will be vary based on the Material Type what u are selectiing , so u have to focus on this settings.
    Regards
    Peram

  • How to handle dynamic screens in bdc

    HI SIR,
    i am working on BDC for CA02 in this i have probelm that if operation 10 it doesnot contains any items it showing one  screen and if operation 10 contain some items
    and its item counter increasing automatically in this case it coming to this screen through some other screen.so.plz help me how to handle this dynamic screens in bdc ,plz help.

    hi sir,
              now i am working BDC UPLOAD with tcode CA02 in this in second screen their are some rows like in table control
    opt
    10                x
    20
    30                 x
    like above in this if row one of column contains 'x' then if i want to fill sub item then it display i one screen EX 100 else if it dsplay screen 200(ie item 10 already contains subitems it display  x in one row column(i.e selected check box) else it show unselected check box.plz tell how to know wheather check box is selected or not from screen to .plz tell.
    thanking u

  • How to handle Dynamic Fiscal calendar

    Hi FolksWe have designed our cubes in such a way that the time dimension is actually split into 2 time dimensions "Fiscal Year" and "Fiscal Time". The "Fiscal Time" changes every four years, in that, it has an extra week. So usually the Month February has 4 Weeks WK01, WK02, WK03, WK04, but this year it has an exta week WK05 and usually WK05 falls under March. So we are not sure how to handle this, other than combining the both dimensions, which has a huge impact on our historical data. And also we think the current design is more elegant, if we do not have this problem. Is there any way we can manage this with out comibing the both time dimensions.1. Fiscal Year FY01 FY02 FY032. FY Time Q1 AUG Q1 Wk01 Sep Oct Q2 Q3 Feb Q3 Wk01 Q3 Wk02 Q3 Wk03 Q3 Wk04

    Hi Nilesh,
    Views will be vary based on the Material Type what u are selectiing , so u have to focus on this settings.
    Regards
    Peram

  • How to handle dynamically created checkboxes in JSP???

    Hello everybody,
    In a JSP page I would like to create checkbox dynamically on every
    result line (detail line), then check in some of them and finally pass the checked lines to a JSP bean which will handle them on a submit button press.
    The problem are:
    - how to index every checkbox in jsp result line in jsp page in order to avoid solutions like this:
    <input type=checkbox" name="value1">
    <input type=checkbox" name="value2">
    etc
    - how to read every checkbox to find the checked ones
    Is there anobody who has any experience from case like this?
    Please, help me.
    Best regards,
    Danny

    Hi, first off, no need to determine what has been checked or not. If the checkbox is checked, on the post, the value will be submitted as part of the request. If the checkbox is not checked, it will not be submitted (it's value will be null). Depending on what you need, I have approached this a number of different ways. One way is to name all checkboxes the same name. If you need to distinguish between two rows in the form, then in the value field for the checkbox, use some type of distinguishing factor, for example,
    <input type=checkbox name=chkName value="1:abc">
    <input type=checkbox name=chkName value="1:def">
    Now, you only have to make one call on the Servlet/JSP receiving the form post, request.getParameterValues("chkName") which will return an array of the non-null Strings that were checked.

  • How to Handle Dynamic Pivoting with a single SQL?

    I was searching for a single SQL who can dynamically understands the pivoting members in the data, I saw several ways of doing Pivoting depending on the version, some are really hard to understand but just two options upto now seams to be flexable enough to do dynamic pivoting, right?
    1- For this option you have to write PL/SQL block to build up the dynamic single SQL query, I also find this approach very easy to understand. :)
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:766825833740
    2- 11.1 's PIVOT new feature with PIVOT XML and ANY clause, a SINGLE SQL and easy to understand but returns XMLTYPE data, another step to parse to produce the report is needed.
    http://www.oracle-developer.net/display.php?id=506
    Below is a 10g Model Clause example, but here instead of pivoting by A1-A2-A3 staticly I want to have these values by a distinc subquery for example;
    create table test(id varchar2(2), des varchar2(4), t number);
    INSERT INTO test values('A','a1',12);
    INSERT INTO test values('A','a2',3);
    INSERT INTO test values('A','a3',1);
    INSERT INTO test values('B','a1',10);
    INSERT INTO test values('B','a2',23);
    INSERT INTO test values('C','a3',45);
    commit;
    SELECT * FROM test;
    ID DES T
    A a1 12
    A a2 3
    A a3 1
    B a1 10
    B a2 23
    C a3 45
    select distinct i, A1, A2, A3
    from test c
    model
    ignore nav
    dimension by(c.id i,c.des d)
    measures(c.t t, 0 A1, 0 A2, 0 A3)
    rules(
    A1[any,any] = t[cv(i),d = 'a1'],
    A2[any,any] = t[cv(i),d = 'a2'],
    A3[any,any] = t[cv(i),d = 'a3']
    I A1 A2 A3
    C 0 0 45
    B 10 23 0
    A 12 3 1 Any advice is appreciated, thank you.

    Hi,
    You can do dynamic SQL in SQL*Plus, also.
    [Thid thread|http://forums.oracle.com/forums/thread.jspa?messageID=2744039&#2744039] shows how to pivot a table with a dynamic number of columns.

  • How to handle dynamic receiver detemination in PI 7.3 java only

    1. I'm doing the file to idoc scenario, i have to give the control record mandatory feilds dyanmically i.e at runtime. what are the steps i need to follow. plz share some relavant documents.
    2. How the dynamic receiver detemination is worked in PI 7.3 java only, share relavant documents.

    1. I'm doing the file to idoc scenario, i have to give the control record mandatory feilds dyanmically i.e at runtime. what are the steps i need to follow. plz share some relavant documents.
    http://forums.sdn.sap.com/thread.jspa?threadID=1901278
    2. How the dynamic receiver detemination is worked in PI 7.3 java only, share relavant documents.
    does not work in 7.3 in ICO - only on dual stack 7.3 without ICO
    and refer below blog
    http://forums.sdn.sap.com/thread.jspa?threadID=2124493

  • How to handle Dynamic File Name

    Hello All,
    I have a  requirement, I have to download a file from application server to my ABAP program which will be executed in the background. The problem is the file name is a dynamic file name with timestamp on it. So how do I read the file from the application server. I know there are certain function modules but I don't think so that they can work in background.
    So If anyone has worked on it before your reply would be helpful.
    Thanks and Regards,
    Sushil

    Hi,
    Use this funcation module this will return you the list of files in a directory...
    It will work even in back group processing also..
    SUBST_GET_FILE_LIST
    or if it is unix environ ment.
    data: begin of t_tabl occurs 0,
    line(132),
    end of t_tabl,
    data: lc_command(100) type c.
    Get all the file name falling under specified directory...
    lc_command(3) = 'ls '.
    lc_command+3(45) = p_dir. " Directory of file path
    call 'SYSTEM' id 'COMMAND' field lc_command
    id 'TAB' field t_tabl-sys.
    Check any files exits in the directory.......................
    if t_tabl[] is initial.
    message e006 with 'No files exist in the specified directory ' p_dir.
    endif.
    here you will have all the file names in t_tab1 you can sort by name and will get the latest file in order..
    Thanks
    Mahesh
    Message was edited by:
            I Can Solve It

  • How to Handle Dynamic actions in batch mode???

    Hello Experts,
    We have a requirement where we need to automate PA40.  The data would be sent in csv file and we need to perform the required steps to insert data into Infotypes.
    The issue is in batch mode (background mode), the dynamic actions wouldn't be called and the business wants the dynamic actions to be considered as well. 
    Pls let me know if there is any way we can interpret the dynamic actions dynamically; meaning the prog should be able to handle the newly created dynamic actions as well.
    Any pointers to this are highly appreciated.
    Regards
    RK

    Hi.
    As far as i know, the limitation comes from the BDC execution itself, it doesn't really matter whether the execution is online or in batch mode.
    * dynamische Massnahme
        IF sy-binpt EQ space.
    *      befinden wir uns im ALE-Eingang ?
          CLEAR: ale_flag.                                   "XFYAHRK063273
          call function 'RHAP_ALE_FLG_GET'                   "XFYAHRK063273
            importing                                        "XFYAHRK063273
              ale_flg = ale_flag.                            "XFYAHRK063273
          IF ale_flag IS INITIAL.                            "XFYAHRK063273
            IF pspar-vinft NE space.  "infotype view         "XYLPH9K007065
              PERFORM dyn_measure IN PROGRAM (view_repid).   "XYLPH9K007065
            ELSE.                                            "XYLPH9K007065
              PERFORM dyn_measure.
            ENDIF.                                           "XYLPH9K007065
            PERFORM process_m
    One thing you could try to do to avoid this and get the dynamic measures executed is to use the NOBINPT variable of the OPTIONS structure in CALL TRANSACTION
      DATA opt TYPE ctu_params.
      opt-dismode = 'A'.
      opt-nobinpt = 'X'.
      CALL TRANSACTION 'PA30' USING bdcdata OPTIONS FROM opt.
      PERFORM close_group.

  • How to handle dynamically generated schemas

    Hello! Experts
    In my last query (subject-- JABX implementation Query)which posted in this forum i asked whether JAXB can be used in situation where schema of the xml files are generate dynamically.I came to know through the reply that JAXB can be used only for static generated schemas.Many Thanks for the reply.
    Can any one suggests how to deal with situations where schemas are generated dynamically?
    Many Regards
    Ved

    This question doesn't make sense. If your code doesn't know anything statically about the schema for an input xml document, the only thing you can do is treat it like a generic xml document using something like DOM, and explore it simply as a tree full of nodes.

  • How-to handle dynamically created AppModules with JUApplication, JUMetaobjectManager

    Hi,
    I've got a JClient App, where I want to dynamically create AppModules in the Context of the RootAppModule.
    How can I best do this??? The problem is that I can't really use the JUMetaObjectManager.createApplicationObject method and hence I can't use PanelBindings.....well I can't use the JClient Framework.
    Is there a way to elegantly manage this issue??
    Every solution would be very appreciated! thanks.

    Hi, first off, no need to determine what has been checked or not. If the checkbox is checked, on the post, the value will be submitted as part of the request. If the checkbox is not checked, it will not be submitted (it's value will be null). Depending on what you need, I have approached this a number of different ways. One way is to name all checkboxes the same name. If you need to distinguish between two rows in the form, then in the value field for the checkbox, use some type of distinguishing factor, for example,
    <input type=checkbox name=chkName value="1:abc">
    <input type=checkbox name=chkName value="1:def">
    Now, you only have to make one call on the Servlet/JSP receiving the form post, request.getParameterValues("chkName") which will return an array of the non-null Strings that were checked.

  • How to handle dynamically created row values when get upadted "please help"

    Hi,
    In my application I have requirement to display the data for specific date when user clicks on viewData. (it shows the entries for that specific days . There may be number of entries). For showing this I have created Value Object and I am setting all the entries for particular selection date to value object and (simply one day entry indicates one instance of my VO if there are 10 entries then I am creating 10 instances of VO and passing this to the actionfor)
    On my JSP page I am displaying that data by using <logic:iterate>
    <logic:iterate id=�myid� name =�nameofform� property =�Listproperty�>
    <tr>
    <td><input type=�text� property=�abc� value=<bean:write name=�myid� property=�propertyinVO�></td>
    // and same for other other values as well
    �.
    </logic:itearte>
    Now I have requirement that if user edit these entries and click on SAVEDATA the updated values should go to the DB.
    As I don�t have property mapped separately I am not able to take updated values of those as they are getting dynamically generated
    Is there is any way by which I can get these updated values.
    I am in badly need of that . Urgent help will highly appreciated.
    Thanks
    Sheena

    Hi, first off, no need to determine what has been checked or not. If the checkbox is checked, on the post, the value will be submitted as part of the request. If the checkbox is not checked, it will not be submitted (it's value will be null). Depending on what you need, I have approached this a number of different ways. One way is to name all checkboxes the same name. If you need to distinguish between two rows in the form, then in the value field for the checkbox, use some type of distinguishing factor, for example,
    <input type=checkbox name=chkName value="1:abc">
    <input type=checkbox name=chkName value="1:def">
    Now, you only have to make one call on the Servlet/JSP receiving the form post, request.getParameterValues("chkName") which will return an array of the non-null Strings that were checked.

  • Handling dynamic item data in VSTS

    Hi Team,
    Can you please let us know how to handle dynamic item data in VSTS.
    Regards
    Raghavendra
    8105577088

    Hi Raghavendra,
    Based on your previous threads posted by you in the test forum, I doubt that you want to create the coded UI test, am I right?
    If so, which kind of app did you want to test, WPF or others? Could you share us a screen shot about the real UI controls you want to test? What real Controls you want to test, list item controls or others?
    You know that to find a control in coded UI test, we have to use the unique peoperties as the search properties, so if your controls are dynamic, the real issue would be related to the search properties you use in your code.
    Like this case:
    https://social.msdn.microsoft.com/Forums/en-US/4c4805f0-230d-459d-a3e5-61e62746c5b9/list-box-item-is-not-get-selected-while-play-back-the-recorded-script-in-coded-ui-test?forum=vsautotest
    As Pankaj's suggestion, if the list items are dynamic then you can use the index values instead of the innertext, so the real issue would be related to how to use the search perperties in your side. If you item text value is dynamic, you'd better not
    use the text value as the search properties. 
    About "How does “Coded UI test” finds a control ??", reference:
    http://blogs.msdn.com/b/balagans/archive/2009/12/28/9941582.aspx
    If I have misunderstood this issue, please feel free to let me know.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to set event handler dynamically?

    Hi all,
    Usually, we add event listener like this:
    myCanvas.addEventListener("click", onClick)
    How can I set the second parameter so that I can add click handler dynamically?
    For example, I have functions clickHandler1, clickHandler2, ...
    And another variable fname: String will contains value1, value2, ...
    Thanks and regards,

    You could do something like this:
    public function firstFunction():void
         trace("First Function");
    public function secondFunction():void
         trace("Second Function");
    public function callFunctionByName(name:String):void
         this[name]();
    public function addEventHandlerByName(handlerName:String):void
         this.addEventListener(Event.ENTER_FRAME, this[handlerName]);
    this.callFunctionByName("firstFunction"); //traces 'First Function'
    this.callFunctionByName("secondFunction"); //traces 'Second Function'
    Let me know if that works for you.

  • Help! dynamic page content - how to handle?

    Hi !
    How do I handle dynamic page content, where for example my jsp page does a post and updates some data, and I dont want the user to use "back" button to go back onto it.
    Hints appreciated
    Cheers
    Steve

    Yes, you can create links for columns in the sql query of a portal report using htf.anchor/htf.anchor2 or just put in your own html code between single quotes. See the [PL/SQL Web Toolkit|http://download-west.oracle.com/docs/cd/B14099_10/web.1012/b15896/toc.htm] for info on the HTF package. There is also a portal Link component which can be created separately and then selected for use on a column in a portal report.

Maybe you are looking for

  • Smoothing and Asset Classes

    Hi Friends, My client wants Smoothing functionality (in transaction ocde oayr) for few asset classes and for few other remaining asset classes - no smoothing functionality is needed How to achoeve this, please can any one explain The smoothing functi

  • I just updated mavericks itunes 11.1.4 and raw camera compatibility update 5.3 and my keyboard wont work. How can i fix it?

    So I updatedmy macbook pro 15in. App store had 1 update for iTunes11.1.4 and RAW camera compatability update 5.3. Minutes after it installed my keyboard quit working. Te only way it works now is by bluetooth keyboard and mouse.  What can I do to fix

  • 1.0.3 status LED behavior changed

    1. When ejected either in iTunes or Finder, status LED IMMEDIATELY switches to green. 2. Unchecking "enable disk use" (and clicking Apply) does NOT affect blinking orange LED either in iTunes or out of it. Thus there's no REAL indicator of charge sta

  • FRM 41032: cannot set enabled attribute of current item B00.CB_EMAIL

    Hi Folks, I am getting the error as shown below in the screenshot. I just changed the background of the form. It was dark in color, so I changed it to brighter colors. There was no change in the code. Please could you let me know, what could be the r

  • OSB NTLM authentication

    Hi. I'm looking for any example to create a passthrougth proxy service on a business service based on an endpoint HTTP that requires basic authentication plus NTLM domain. I haven't OWSM on this OSB. TIA Corrado