How to Handle Events for JOptionPane buttons?

Hi All,
I need a help...
I am trying to develop a simple SWING application that consists of multiple elements (mainly text fields) and a Submit button. On pressing Submit button, it should validate all the fields and then do something else. But if some fields are left blank, then it should give a pop-up message and on clicking the OK button on the pop-up message, the focus should go to that text field which is left null.
The problem is I am not able to understand how to Capture this OK button click-event of the pop-up message. I mean how to do something when the OK/Cancle button of the pop-up window is clicked.
Please Help me.
Thanks in Advance,
Ujjal

As already pointed out, JOptionPane has some static methods which show a dialog, and return an int, or a string. The whole point of this class is to remove the need for any event handling by the developer, that is, you simply call the showDialog method or whatever, and it returns a value telling you, for example, which button was pressed - no need for action listeners at all. The result of the showDialog method (or whichever you use) tells you which button was pressed. Check the javadocs for JOptionPane for details of several constants that indicate which button was pressed
The class exists to make simple dialogs trivial to generate - you're overcomplicating things!

Similar Messages

  • How the PCUI event for export button works?

    Hi All,
    After get the order search result in PCUI, when I click the Export button.
    It show me the message that : Microsoft office 2003 or higher is not installed on your computer.
    In fact, I have the office 2003. And I found that the event for Export button is PCF_DL_EXPORT.

    Have you tried double-clicking on the auto complete component in the designer? You should be taken to a method like "autocomplete1_complete". This method is called when the autocomplete gets focus and also for each character typed in the field.
    Cheers!
    -David

  • ALV: how to handle event for multi (lead) row selection ?

    Hi,
    I use editable ALV and configure it for multi (lead) selection. Works fine.
    But I could not find any event handler for reading the selected lines.
    There is only the Event handler ON_LEAD_SELECT: this works only for 1 line
    (the lead line). But I could not read multi lines. Who can help?
    Thanks in advance, Christian

    Hi Christian,
    did you try a custom button?
    Try a call
    node->GET_SELECTED_ELEMENTS
    I cant remember if ALV sends event when multi-selection is on for each row selection.
    ie as each row is selected, do you get control ?
    If so, then you should still be able to call node->GET_SELECTED_ELEMENTS .
    regards
    Phil.

  • How to handle events for Tab Control

    Hi,
    I have a Tab control with 4 tabs and I would like when I go to a specific tab all the contents of that tab being updated. Could you please help me with this?
    How should I set the event structure
    Thanks

    Tab Control->Value Change is the event you want.  You can then use a case structure to do whatever you need it to based on the "New Value".
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Writting Events for TableView Buttons

    Hi SDN,
    I created a table view in a jsp dynpage which has one of the columns type as button.i got it by using "setColumnType" attribute of tableview.
    now i want to fire server and client events onclick of those buttons.how to achieve it? can we write client and server events for those buttons as like normal buttons.
    if yes tell me how and where to write?
    explain me with example (coding) if possible.
    Thanks & Regards,
    Art.
    /points will be rewarded/

    Hi Subathra,
    Thank you for ur reply.i know that we can achieve it using "setOnCellClick " but i want to know whether we can use the normal attributes of a button for this button placed in a cell of a tableview.
    if yes how to use it.is there any relation between cell renderer attribute and my requirement.
    <b><u>Note:</u></b>
    you can share ur ideas about other components also which can be used in a tableview (inputfield,link,image...) and writting events for those components.
    Thanks & Regards,
    Art

  • Contextual Event for a Button in Dialogue (inline popup)

    I have dialogue(in-line popup window) which opens on click of button "viewPopUp" in parent window.
    I have a table and "select" button inside dialogue. I have contextual event created for this button inside child wondow.
    It never works for me. Its not calling the event handler method. But, If I add a contextual event for the button "viewPopUp" on the parent page works fine.
    Anybody faced similar issue?
    Any idea or tips to get it work?
    Edited by: sideeque on Sep 17, 2011 11:08 PM
    Edited by: sideeque on Sep 17, 2011 11:09 PM

    I use JDeveloper 11.1.1.5. I might be doing something wrong here. Do you have the sample code to share and test in JDeveloper 11.1.1.5? Is it running for you in JDeveloper 11.1.1.5 version?

  • How to handle Events in OO abap.

    Hii all as im new to SAP and  ABAP , i want to know , what are events all about and how to handle events?
    Like how to guide double click to call a transaction , or to create a hot sopt and then , calling the transaction...........
    Please Help.

    Hi Chandan,
    possibly you are not just new to ABAP but new to obeject oriented programming in general. In oo, you use events to trigger methods that are registered as 'listeners' for the event.
    As I have no idea on your current knowledge, I don't know what I could recommend to start with.
    My personal approach is first to have a task I want to complete and then find and understand the methods to get there.
    Regards,
    Clemens

  • How to handle "ok" and "cancel" button of dialog popup?

    Hello everyone,
    I'm using a dialog with type="okCancel". My question is how to handle ok and cancel button of this popup window. Here is my code below:
    <af:popup id="kriterPopup">
    <af:dialog title="Kriter Seçiniz" type="okCancel" inlineStyle="width:500px;height:400;" id="d2"
    dialogListener="#{BasvuruDegerlendirmeBean.kriterDialog}">
    <af:selectManyCheckbox label="Kriterler :" id="smc2"
    binding="#{BasvuruDegerlendirmeBean.kritersCheckbox}">
    <af:forEach items="#{BasvuruDegerlendirmeBean.kriterList}" var="item">
    <f:selectItem itemLabel="#{item.ybKriter.tur}" itemValue="#{item.ybKriter.tur}" id="si3"/>
    </af:forEach>
    </af:selectManyCheckbox>
    </af:dialog>
    </af:popup>
    I want to handle ok and cancel button of this window, and redirect to the pages which I want.
    Can anyone help me how I can do?
    Thanks, with my regards.
    Ali

    You need dialogListener..
        public void dialog1_dialogListener(DialogEvent dialogEvent) {
            if (dialogEvent.getOutcome().equals(DialogEvent.Outcome.yes)){ //for Yes
            }else{ //for Cancel
        }

  • How to handle Event in JACOB API

    Hi,
    I am read the outlook mail using JACOB[Java Com Bridge] API successfully, now i want to handle events for outlook mail using JACOB. and also i can able to catch the new mail event. but i am unable to catch any deleted mail and move mail from one folder to another folder. This is extremely important for my project. so any one please tell me how to handle and catch the Outlook deleted event and move event using JACOB.
    Thanks in Advance,
    With Regards,
    Ganesh

    Windows can be closed in a number of ways and the simplest way to trap them would be to handle Window Closing in code behind.
    This is also the easiest way to show dialogs if that's how you wanted the warning message to appear.
    This:
    chxAllowToClose.IsChecked
    Looks like a checkbox to me, seeing as you have IsChecked.
    That presumably means you already have that bound to a viewmodel and visible to the user.
    You can therefore just test that value from the view.
    If you prefer to hide that instead then there are several options.
    You could have a dependency property and a binding in code behind which binds to the viewmodel. Test that in your event.
    Or
    You could save the value when it changes to application.current.resources.  Since dependency properties and bindings are a bit wordy this is easier.
    Or
    You could have just a variable in the view code behind and use messenger to tell that when the value changes from the viewmodel:
    http://social.technet.microsoft.com/wiki/contents/articles/26070.communicating-between-classes.aspx
    Please don't forget to upvote posts which you like and mark those which answer your question.
    My latest Technet article - Dynamic XAML

  • Handling events for

    I have a JApplet (menuhandle.java) that adds a menubar. While handling events for the "Open" menu item under File menu(to make it show the OpenFileDialog box) a NullPointerException was thrown. How should this be overcome?
    public void actionPerformed(ActionEvent e)
    if (e.getActionCommand() =="Open")
    chooser = new JFileChooser();
    int returnVal = chooser.showOpenDialog(new menuhandle());
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    ExampleFileFilter filter = new ExampleFileFilter();
    filter.addExtension("dcm");
    filter.setDescription("Dicom files");
    chooser.setFileFilter(filter);
    if(returnVal == JFileChooser.APPROVE_OPTION)
    File file=chooser.getSelectedFile();
    if(filter.accept(file))
    str=file.getName();
    I need to display the Open File dialog box and also retrieve the file the user actually selected, in order to do certain manipulations with it. Can somebody tell me how to go about this?

    Just a guess, but could the problem be related tothe
    fact that for security purposes many file
    manipulation functionality is disabled in applets?Indeed. The SecurityManager for unsigned applets does
    not allow the use of JFileChooser
    Thanx a lot. But if i make menuhandle .java as a simple class (without extending JApplet) and then try to use this class from inside another applet........will this work? Or will the SecurityManager still not allow the use?

  • How to create EVENTS for a View Cluster.

    Hi Tech Gurus,
    I have created a view cluster on 5 tables. I need to do a validation and this can be done by using events. But i am unable to create a EVENT for the View Cluster. Could anyone please tell me how to create events for a View Cluster.
    Thanks in advance for your esteemed replies.
    Regards,
    Raghavendra Goutham P.

    Hello Pasapula
    When you are in the View Cluster maintenance dialog (SE54) click on dialog "Events".
    Below the field for the view cluster you have an additional field <b>FORM routines main program</b>. There you have to add the main program containing the FORM routines called by the VC events.
    For example: I had defined a normal report containing an include with all the FORM routines. The report contains only the following lines of coding:
    report zus_0120_u1.
    * Common Data und access routines for user exits in VC maintenance
    include LSVCMCOD.
    include  zus_0120_f1. "FORM routines for VC events
    Now in the "Events" dialog of the view cluster maintenance you assign your FORM routines to the events.
    Regards
      Uwe

  • How to handle bdc for more than one transaction?

    how to handle bdc for more than one transaction?

    Hi srk,
    I am providing you with some references below. Hope this prove to be helpful to you.
    Method 1:
    Use one BDC_OPEN_GROUP
    Multiple BDC_INSERT 
    One BDC_CLOSE_GROUP.
    Call function BDC_OPENGROUP.
    Build BDC data and call lBDC_INSERT for transaction 1
    Build BDC data and call lBDC_INSERT for transaction 2
    Build BDC data and call lBDC_INSERT for transaction 3
    paas the tcodes to bdc_insert.
    call function BDC_CLOSE_GROUP.
    Also check this out:
    Here we need to record 2 transactions (shdb).
    Once completion of the recording. Populate the data into input internal table .
    Loop the internal table and process the 2 transactions
    like
    1. BDC_OPEN_GROUP
    2. LOOP AT ITAB
    a. Populate first transaction recording data
    and pass transaction to the BDC_INSERT_GROUP.
    BDC_INSERT_GROUP.
    b. Populate second transaction recording data
    and pass transaction to the BDC_INSERT_GROUP.
    BDC_INSERT_GROUP.
    ENDLOOP.
    3. BDC_CLOSE_GROUP
    the above info can be found at : How to use 2 transactions in BDC?
    Also check this out:
    Suppose u have created recordings for transactions 'MM01' 'XK01' and 'VA01'.
    Then do this:
    bdc_open_group.
    after this we have to fill the bdcdata structure for one transaction.here 'MM01'.
    bdc_insert.
    refresh bdcdata.
    after this we have to fill the bdcdata structure for one transaction.here 'xk01'.
    bdc_insert .
    refresh bdcdata.
    after this we have to fill the bdcdata structure for one transaction.here 'va01'.
    bdc_insert.
    bdc_close_group.
    Hope these are useful to you.
    Please reward if any of the above are useful.
    Regards,
    Kalyan

  • How to set value for radio button in sap crm survey suite

    Hi ,
    I created a survey in CRM Service, in which I added a question with answer as '10 Selection Button Group ('radio button'). And answer has 11 answer options (which means 11 radio buttions). Now when we test the survey, the value for the radio buttons is appearing like 'id_0050569b03091ee480a29d8ee61e953c'. But i want to set a specific value for each radion button (from 1 to 11). So, how to set value for radio button in sap crm survey suite???.
    Thanks & Regards,
    Seshu

    Hi,
    I found solution myself. Click on Goto -> Editing Mode -> Expert Mode. Now you can set value for radio button.
    Regards,
    Seshu

  • How to add a new button in IC tool bar and handle the event for the button?

    Hi,
        I am working on CRM 2007 Interaction center. To add a new button to IC toolbar, customizing is available to define a new button and then assign in to the profile.
    In SPRO->CRM->IC webclient->Customer Specifc System Modifications->Define Toolbar Buttons, I defined one new button with ID ZSTART.
    Now in SPRO->CRM->IC webclient->Basic Functions->Communication Channels->Define Toolbar Profiles , I selected Default profileid and in Generic Layout Buttons Tab, I added the new button ZSTART in Position 3.
         So after completing the customizing when the user logs in using role IC_AGENT,  the button (with ID:ZSTART) gets displayed in the IC toolbar too.
          Now on click of this button, I need to create an object.
    To do so, I have to catch the event which is raised by this new button.
           Please let me how to implement the event handler for this new button. What will be the event name for this button click event and how I can subscribe for it ?
         Please let me know if anyone of you have already worked on similar requirements.
    Regards,
    Manas.
    Edited by: manas sahoo on Jul 22, 2008 7:49 PM

    Hello Manas,
    There are a couple of threads in the community that might help you out (if you haven't already found them):
    Re: IC Web Client Toolbar
    /message/3621917#3621917 [original link is broken]
    Regards,
    Renee Wilhelm
    Edited by: Renee Wilhelm on Nov 6, 2008 7:46 PM

  • How to handle event structures for two buttons and two counters.

         *I have two buttons A and B, and have to compare the difference in hits between them.  So do I place an event structure within a while loop for each button (2 buttons, 2 event structures, 2 while loops), or does it need to be one event structure with cases for both buttons whithin one while loop? 
         *How do I pass the values of buttons A and B's hit counters out of the while loop in order to calculate the differences between them after each increment, not just the final count after the stop button is hit? 
         *How would I make one stop button work to handle both buttons A and B?   I tried to place the actual stop button in one button A's structure and its global in B's structure, but It wont seem to let me use a local variable for a latchable control
    Checker

    You should probably have not started a new thread and waited until your question in the original thread was answered. You can modify altenbach's example for a second button. You have a single event structure with a new event for the second button. You have a second shift register to track the number of times the second button is pressed. Inside the while loop but outside the event structure, you just have a subtract function in or to report the difference. do not modify the posted example for the stop button. It works perfectly as is.

Maybe you are looking for