Which button is clicked?

hello,
I have a an array of buttons, which has 20 buttons.
How can I know which button is clicked inside actionPerformed method.
THANKS
Chamal.

Search for the Java Tutorial and carefully read the section on event listeners. You can find lots of sample code there.
Basically, you can branch on action commands (typically the label on the button) or event sources (a reference to the object which fired the event). The second method is preferrable to the first, particularly with regard to internationalized applications.

Similar Messages

  • How to identify which button is clicked in an action

    Hi,
    I am just checking whether it is possible to build calculator or not in webdynpro for abap.
    I have some buttons and i have associated same action for all the buttons and in that action i would like to know which button is clicked.
    Please let me know the code for that
    Thanks
    Bala Duvvuri

    Hi Bala,
    Its possible. Just go to the action handler for the button & read the attribute ID of the WDEVENT which is passed by the framework. This id will contain the id of the button which triggered the event. Consider the code fragment below:
    method ONACTIONACTION .
        DATA:  lv_button_name type string.
        lv_button_name = wdevent->get_string( name = 'ID' ).
    endmethod.
    At the end of execution lv_button_name will have the ID of the button which triggered the event.
    Regards,
    Uday

  • How can I find which button is clicked?

    I have two buttons on my page.Is there any way so that I can find which button is clicked in my JSP page?I do not know javascript I tried to pass a parameter by url rewriting through a Javascript function to another page.
    But it did not work? how can I do this?
    Can I return a parameter from javascript to a JSP page?
    Plz help me
    Thanks in advance
    Amit Varshney

    If you give the submit button a "name" attribute, the name of the button you pushed will come through as a parameter, along with its "value" (the text on the button)
    ie
    // in your jsp page
    <input type='submit' name='button1' value='FromB1'>
    <input type='submit' name='button2' value='FromB2'>
    // in your servlet code...
    boolean b1Pressed = request.getParameter("button1") != null;
    boolean b2Pressed = request.getParameter("button2") != null;

  • Determine which button is clicked

    I am creating the download buttons on my page dynamically and I am assigning the name also dynamically attaching the counter with the name. Now On form post, i want to know which button( button at which counter ) was being pressed. Could u help me on this.

    Use request.getParameterNames( ) to get an enumeration of all the names passed by the form. You can then go through the list and determine which button was pressed since the name of that button would be passed along.
    If you are uncomfortable with using the enumeration technique, do a request.getParameter( button_name ) for each button and check whether you get a null value which implies the button wasn't pressed, or the counter value, which implies the button was pressed. If you have a lot of buttons, this results in some redundant code, but if you have only one or three, then this is probably an ok way to do it.

  • Trying to get a movie clip to go both up and down depending on which button gets clicked

    hello,
    I have a file with 5 movie clips in it. I have a button that when clicks, plays each one. One of the movie clips needs to move both up and down and I am having a lot of trouble with this.
    stop();
    function showVenue(Event:MouseEvent):void
              mc_speaker.play();
    function showSpeaker(Event:MouseEvent):void
              mc_compliance.play();
    function showCompliance(Event:MouseEvent):void
              mc_strategic.play();
              mc_data.play();
    function showStrategic(Event:MouseEvent):void
              mc_data.gotoAndPlay("down");
    function showData(Event:MouseEvent):void
              mc_data.gotoAndPlay("up");
    btn_viewMore_Venue.addEventListener(MouseEvent.CLICK, showVenue);
    btn_viewMore_Speaker.addEventListener(MouseEvent.CLICK, showSpeaker);
    btn_viewMore_Complinace.addEventListener(MouseEvent.CLICK, showCompliance);
    btn_viewMore_Strategic.addEventListener(MouseEvent.CLICK, showStrategic);
    btn_viewMore_Data.addEventListener(MouseEvent.CLICK, showData);
    Is there anyway to attach my file here for someone to look at???
    thanks!
    babs

    Well, on the mc_data movie clip, I had the animation going up and down with stop actions to stop it. so I put labels on those areas and tried to just control it that way. Seemed simple enough, but not working.
    I really don't know how to control the toggle up and down in AS without using the timeline....just trying to help a friend, and ready to scream..I thought this would be so simple...
    would be easier to explain if I could show you a dummy file...but I still don't see an attach button????

  • Knowing which button is clicked

    i have code that creates button objects ,stores them in array
    and adds action listeners as follows.i want to code clickstart such
    that i can change the label of the clicked button.
    var buttonlist=new Array();
    for(var i:int=0;i<10;i++){
    mybutton=new Button();
    mybutton.x=10;
    mybutton.y=10+50*i;
    mybutton.width=50;
    mybutton.height=50;
    mybutton.label="no:"+i;
    mybutton.addEventListener(MouseEvent.CLICK,clickStart)
    mycanvas.addChild(mybutton);
    buttonlist.push(mybutton);
    thank you

    Try this:
    private function clickStart(evt:MouseEvent):void {
    evt.currentTarget.label = "some new label";
    Vygo

  • Making a text field required when a radio button is clicked

    Hello all, I am very new to designing PDF forms, and I want to implement this requirement but have no idea how to go about doing it. I am designing an order form, and in a few different sections of the form are text fields that I want to be required, but only if a certain radio button on the form is clicked. So for example, I have a radio button group on the page consisting of two buttons, and then immediately to the right is a text field. If the user selects button 1, the text field is not required, but if they select button two, the text field is required. How do I implement this? I am using Livecycle ES3. And when I say required, I am referring to the field value/property of "User Entered - Required". Also, I cannot accomplish this by hiding and unhiding the field depending on which button is clicked, as this form will also be printed and filled out by hand, so all fields must be visible at all times. This form does have a submit by e-mail button and that is how it will be used primarily.
    Also, I have searched around the forums a bit, and have tried some Javascript I have found, tying it to a mouseup event on the radio button, for example "getField("Text1").required = (getField("Radio1").value == "Yes");" and "getField("Text1").required = true;" with the names changed for my fields, but no matter what I try it has no effect
    Thanks!

    i hope this helps u.You can always optimize tht code a bit more , it's coded roughly but it works.
    <html>
    <head>
    <script>
    var cursel='r1';
    function radioClick(x)
         if(cursel!=x)
              cursel=x;
         if(cursel=='r2')
              var z=document.getElementById('mydiv');
              mydiv.innerHTML='<input type=text name=ss size=20/>';
              mydiv.style.display='inline';
         else
              var z=document.getElementById('mydiv');
              mydiv.innerHTML='';
              mydiv.style.display='inline';
    </script>
    </head>
    <body>
    <form>
    <input type=radio name=rtt onClick="radioClick('r1');" checked />Radio 1
    <br>
    <input type=radio name=rtt  onClick="radioClick('r2');"/>Radio 2
    <br>
    <div id=mydiv></div>
    </form>
    </body>
    </html>

  • How to get a node  in a Jtree on which right mouse button is clicked

    I am dealing with a situation in which whenever tree component is clicked by right mouse button I am needed to get the tree node on which right mouse button was clicked.

    MouseEvent e = ...
    TreePath path = tree.getPathForLocation(e.getX(), e.getY());
    Object nodeClickedOn = path.getLastPathComponent();Or something along those lines.

  • Friend help me to fix my laptop and runing the program Piriform CCleaner and is finish but which button should I click - Analyze or Run Cleaner

    Need a big help!! A Friend help me to fix my laptop and runing the program Piriform CCleaner and is finish but which button should I click - Analyze or Run Cleaner

    Laptop? this is the ipad forum.
    Is your laptop a macbook? If so I can have the hosts move your post there
    But for specific info about a non-apple program, the best place to look is on the site for the program you're using, In your case Piriform's site.

  • Flex + Multiple Routes, which button clicked?

    I have a User Task (which uses a Flex form) in workbench which has 2 defined routes leading out of it, Approve and Reject. If Accept, a bunch of validation should occur. If Reject, no validation is needed.
    When the user clicks on either of these buttons in the bottom of Workspace, I receive an event within Flex, which typically kicks of my validations. But, both buttons fire off this event and I don't see any way of telling which of the 2 buttons was clicked.
    Anyone have an idea

    Hello,
    At your PDDF form you have controls loke this : AWS_SUBMIT, AWS_ACTION, AWS_PROCESSTYPE etc.
    AWS_SUBMIT it is button, you can put some javascript code on it's onClick event , which will make youre validation.
    Example:
    prodata.AWS_SUBMIT::click - (JavaScript, client)
    // This is the AWS_SUBMIT click script
    if (xfa.host.name == "Acrobat")
    //validation
    if (prodata.AWS_ACTION.rawValue == "Cancel"){
    data.main.field.validate.nullTest = "";
    if (prodata.AWS_ACTION.rawValue == "Approve"){
    data.main.field.validate.nullTest = "Error";

  • SRM RFx Response - How to check if a button is clicked or not

    Hi All,
    This is rani.  Im very new to SAP.
    Im into my first project, in which im having an Immediate enhacement.
    In SRM Portal, I need to logged in as bidder to create a bid response.
    "Participate" button is there, i need to clicked that button, this is mandatory.
    So how and where to check whether the button is clicked or not.
    else i need to raise the error message in BBP_DOC_CHECK_BADI and some fileds needs to be grayed out.
    The webdynpro component is FPM_OIF_COMPONENT.
    Can u please help me out in this regard.
    Thanks in Advance,
    Rani.

    Hi  Rani ,
    In SRM 7.0 the system variables ( sy-ucomm & sy-Tcode ) will not work .
    if you want the action code  triggered in the  Webdynpro screen inside the BADI: BBP_DOC_CHECK_BADI
    kindly study the SAP Note 1334202 - How to get current action ID and transaction group
    Below piece of code will give you the action Id in side the badi
    DATA: lo_trans_context TYPE REF TO /sapsrm/if_transaction_context,
            lv_action        TYPE /sapsrm/pdo_action_type,
            lv_tcode         TYPE /sapsrm/transaction_group.
      lo_trans_context = /sapsrm/cl_transaction_context=>/sapsrm/if_transaction_context~get_instance( ) .
      lv_action = lo_trans_context->get_current_action( ). "  replacement for sy-ucomm
      lv_tcode  = lo_trans_context->get_transaction_group( )." replace ment for sy-tcode
    kindly go through the SAP note provided .
    Regards
    Chinnaiya P
    Edited by: chinnaiya pandiyan on Jun 27, 2011 7:34 PM

  • How to check if a button is clicked or not

    Hi All,
    This is rani.  Im very new to SAP.
    Im into my first project, in which im having an immediate enhancement.
    In SRM Portal, I need to logged in as bidder to create a bid response.
    Participate button is there, i need to clicked that button, this is mandatory.
    So how and where to check whether the button is clicked or not.
    else i need to raise the error message in BBP_DOC_CHECK_BADI and some fileds needs to be grayed out.
    The webdynpro component is FPM_OIF_COMPONENT.
    Can u please help me out in this regard.
    Thanks in Advance,
    Rani.

    HI,rani;
       you can use the FM  :BBP_PD_BID_GETDETAIL ,you will get the detail of the Rfx ,and check the status of the Rfx !
       Alex

  • How to Create a Dynamic http address that opens the Explorer Window for a List Item When a Button Is Clicked--Currently Trying to Make this Work with Javascript

    I have created a button (via Content Editor) that uses JavaScript to open the Attachments folder of a list item in the Explorer Window in SharePoint 2010. The purpose is to have drag and drop functionality for each list item, having multiple attachments.
    The button works but opens the "Attachments" folder containing all of the other folders for each list item (one folder per item). It seems that when you add an attachment to a list item, SharePoint numbers the folder based on the item's ID. What
    I'm trying to do is take the JavaScript I have and have it run when a button is clicked in a custom form. When it runs, I'm trying to get it to open the "specific" folder for the list item. I have had success creating a hyperlink in the list that
    does this; however, the link WILL NOT work until I use the Content Editor created button that runs JavaScript, that prompts me to click OK to my profile certificate, and then opens the Attachment folder. After that occurs, I can use my hyperlinks without issue
    because I'm no longer prompted to click OK for my cert.
    So I'm trying to take the JavaScript I have and place it in a list item form (custom form) and have it run when a form button is clicked. The problem is I have very little knowledge of JavaScript (did I mention little?) and
    "don't know how to take the "http:" address I have in the script and append to it the list item ID, according to the record I have open."
    So that for any record I open, the script will grab the corresponding record ID (or list item ID) and append it.
    Here's the script I'm working with (which I didn't create but am grateful for):
    <style>
    .httpFolder {behavior:url(#default#httpFolder);}
    </style>
    <script text = "javascript">
       function fnOpenFolderView(){
       oDAV.navigateFrame("https://server/collection/site/subsite/Lists/Sublist/Attachments","_self");
    </script>
    <div id = "oDAV" class = "httpFolder"/>
    <input type = "button" value = "Open Attachment Folder" onclick = "fnOpenFolderView()"/>
    The above script, in the Content Editor, creates a button that opens the Attachments folder for the corresponding SharePoint list.
    JackSki123

    Hello Thriggle,
    Thank you for pointing that out. I appended your "GetUrlKeyValue" to the end and it worked. That said, I noticed it doesn't run as smoothly as when I simply click on the Content Editor button I created that resides on the SharePoint List
    ASPX page (not the form). The Content Editor button has the same code, minus the "GetUrlKeyValue". I click it; I get prompted to choose my cert; it opens right up.
    Now go to the ASPX Display form where I dump the code in a table cell. Button appears in cell; I click it; wait; wait; I get prompted for cert; it opens. Do I need some sort of "throttle" for the JavaScript? For instance, I thought before running
    JavaScript, you reference the library first. This code doesn't do that. I'm wondering if there's something more I need to make this run smoothly. Thank you both for getting me this far. 
    JackSki123

  • ADF: How to find out if a button is clicked?

    Hi,
    I want to check if a button is clicked/selected and specify that condition as something like: #{backingBeanScope.backing_SearchLog.cb1 eq true}  in the refreshCondition of one of the viewIterator.
    Kindly let me know how to check if the button is clicked?
    Thanks,
    Kalpana.

    Hi Timo,
    This discussion is related to ADF: Query being called automatically on selecting a value from LOV. posted by myself, i can say it as an extension.
    I have two LOVs on my page and a SUBMIT button, currently what is happening is, when i select a values from the LOVs the query is being fired(which is supposed to be fired only after the click of SUBMIT button). The query is being fired on first LOV, second LOV and on SUBMIT button also which i want to avoid. I want the query to be fired only on SUBMIT button that is why i want to put a refreshCondition on the viewIterator of the query as 'if SUBMIT button is clicked'.
    Kindly let me know if it not clear.
    Thanks in advance,
    Kalpana.

  • Problem with getting specific canvas's to display within a viewstack based on button's clicked within a tilelist

    In a new application I'm creating I've managed to set it up so that a user can add up to 5 'user profile buttons' by clicking an 'add item' button and remove each one by clicking an 'remove item' when they are selected.
    That part works fine, however once each button is clicked it should bring up a specific canvas view within the viewstack relevant to that particular button i.e. when a user clicks the 'New Profile 1' button the 'New Profile 1' Canvas view should then be displayed in the viewstack, when they click 'New Profile 2' it should display 'New Profile 2' canvas in the viewstack etc but I am having trouble linking each specific button to 1 specific Viewstack canvas.
    The problem is if, for example, I click the 'New Profile 2' button the 'New Profile 2' canvas IS displayed in the viewstack however if I then delete the selected 'New Profile 2' button the 'New Profile 3' button slides left into it's place but now clicking on New Profile 3 brings up the new profile 2 canvas whereas it should actually bring up the new profile 3 canvas at all times.
    Eventually these canvas's will be personal areas for specific users so it is important that each button in the tilelist links to that specific user but it is also important that a user can add/delete each button at all times.
    I've already had the first part of this problem (which was linking the tilelist to the viewstack) more or less answered but I clicked Correct answer rather than helpful answer in my previous thread. My mistake, sorry. Is ther a better way to do this application. Heres my code so far:-
    <?xml version="1.0" encoding="utf-8"?>
     <mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:components="components.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#545351, #E3DFDF]">
    <mx:Script>
    <![CDATA[
    import mx.managers.*; 
    private var _dragManager:DragManager; 
    private var _historyManager:HistoryManager; 
    private var _popupManager:PopUpManager; 
    import flash.net.navigateToURL; 
    import flash.net.URLRequest; 
    import flash.net.URLVariables;  
    import mx.events.ListEvent;  
    import mx.controls.Button; 
    import mx.collections.*; 
    import mx.controls.Alert;]]>
    </mx:Script>
    <mx:Script>
    <![CDATA[
    import mx.effects.easing.Elastic; 
    import mx.collections.ArrayCollection; 
    Bindable] 
    private var myDP:ArrayCollection = new ArrayCollection();
    private var dpArr:Array = [{label:"New Profile 1", data:View1},{label:"New Profile 2", data:View2}, {label:"New Profile 3", data:View3},{label:"New Profile 4", data:View4}, {label:"New Profile 5", data:View5}]; 
    private var addedIndices:ArrayCollection = new ArrayCollection(); 
    private function deleteItem():void { 
    if(myDP.length > 0){ 
    for each(var i:int in tlist0.selectedIndices)myDP.removeItemAt(i);
    private function addItem():void { 
    if(myDP.length < dpArr.length && addedIndices.length < dpArr.length){ 
    for(var a:uint = 0; a < dpArr.length; a++){ 
    if(!addedIndices.contains(a) && !myDP.contains(dpArr[a])){myDP.addItemAt(dpArr[a],myDP.length);
    break;}
    private function tileList_itemClick(event:ListEvent):void { 
    private function showAlert(event:ListEvent):void{ Alert.show(
    "You clicked button #"+event.currentTarget.selectedItem.data);}
    ]]>
    </mx:Script>
    <mx:Sequence id="itemsChangeEffect1">
    <mx:Blur blurYTo="12" blurXTo="12" duration="300" perElementOffset="150" filter="removeItem"/>
    <mx:Parallel>
    <mx:Move duration="750" easingFunction="{Elastic.easeOut}" perElementOffset="20"/>
    <mx:RemoveItemAction startDelay="400" filter="removeItem"/>
    <mx:AddItemAction startDelay="400" filter="addItem"/>
    <mx:Blur startDelay="410" blurXFrom="18" blurYFrom="18" blurXTo="0" blurYTo="0" duration="300" filter="addItem"/>
    </mx:Parallel>
    </mx:Sequence>
    <mx:Canvas width="1168" height="716" backgroundColor="#0219FB" horizontalCenter="0" verticalCenter="0" borderColor="#000000" borderStyle="solid" borderThickness="1" cornerRadius="20" backgroundAlpha="0.8">
    <mx:Canvas id="UserArea" left="10" x="0" y="49" width="670" height="594" backgroundColor="#000000" cornerRadius="20" borderStyle="solid">
    <mx:TileList id="tlist0" itemClick="myViewStack.selectedIndex=tlist0.selectedIndex" itemRenderer="mx.controls.Button" top="10" left="10" right="10" color="#FFFFFF" height="50" width="100%" fontSize="12" fontStyle="bold" columnCount="5" rowCount="2" direction="horizontal" dataProvider="{myDP}" itemsChangeEffect="{itemsChangeEffect1}" backgroundColor="#000000" fontWeight="bold" borderStyle="none"/>
    <mx:Canvas x="63" y="129" width="200" height="200" fontSize="36" borderColor="#FFFFFF" id="Canvas1" visible="false">
    <mx:Label x="27" y="25" text="Profile 1"/>
    </mx:Canvas>
    <mx:ViewStack x="115" y="88" id="myViewStack" width="382" height="317" backgroundColor="#F90C0C">
    <mx:Canvas id="View1" label="View 1" width="100%" height="100%" backgroundColor="#0FDDE5">
    <mx:Label x="10" y="10" text="NEW PROFILE 1" fontWeight="bold" fontSize="15"/>
    </mx:Canvas>
    <mx:Canvas id="View2" label="View 2" width="100%" height="100%" backgroundColor="#A90BCB">
    <mx:Label x="10" y="10" text="NEW PROFILE 2" fontWeight="bold" fontSize="15"/>
    </mx:Canvas>
    <mx:Canvas id="View3" label="View 3" width="100%" height="100%" backgroundColor="#E6E413">
    <mx:Label x="10" y="10" text="NEW PROFILE 3" fontWeight="bold" fontSize="15"/>
    </mx:Canvas>
    <mx:Canvas id="View4" label="View 4" width="100%" height="100%" backgroundColor="#F4A40A">
    <mx:Label x="10" y="10" text="NEW PROFILE 4" fontWeight="bold" fontSize="15"/>
    </mx:Canvas>
    <mx:Canvas id="View5" label="View 5" width="100%" height="100%" backgroundColor="#0D1DFA">
    <mx:Label x="10" y="10" text="NEW PROFILE 5" fontWeight="bold" fontSize="15" color="#FFFFFF"/>
    </mx:Canvas>
    </mx:ViewStack>
    </mx:Canvas>
    <mx:Button label="Remove item" click="deleteItem();" color="0x323232" x="96" y="10"/>
    <mx:Button label="Add item" click="addItem();" color="0x323232" x="10" y="10"/>
    </mx:Canvas>
     </mx:Application>

    Hi
    Try this if it works..
    1. In MultiProvider identify those key figure from both the InfoProvider ( DSOs)
    2. In BEx create KF1 . Restrict with 0INFOPROV = DSO1 ( Billing) , hide it
    3. Create KF2 . Restrict with 0INFOPROV = Cube ( condition cube) , hide it
    3. Create a Fomula Key Figure 3 with the definition
    KF3 =  KF1 + KF2* ( KF1==0)
    If KF1 is zero, then KF1 == 0  will be true and it will return value 1.  So, basically you would get
    KF3 = 0 + KF2 *1 = KF2
    When KF1 is non-zero, expression KF1== 0 will be false and gives a value 0. Let;s say KF1 =5 , then
    KF3 = 5 + KF2 * 0 = 5
    Now show KF3 in the report
    Regards
    Anindya

Maybe you are looking for