How to close dialog?

hello
in frame i do a dialog box and i put button in that dialog box that to close the dialog ....but i faild how can i close the dialog.....the code that i use is:
import java.awt.*;
import java.awt.event.*;
public class DialogExample extends Frame {
Dialog dialog;
public static void main(String args[]){
DialogExample win = new DialogExample();
public DialogExample() {
super("DialogExample");
pack();
resize(400,400);
addMenus();
createDialog();
show();
void addMenus() {
MenuBar menubar = new MenuBar();
Menu dialog = new Menu("Dialog");
dialog.add("Show");
menubar.add(dialog);
setMenuBar(menubar);
public void createDialog() {
     dialog = new Dialog(this,"Dialog Box",false);
     dialog.resize(200,200);
     Button close      = new Button("close");
     dialog.add(close);
public boolean action(Event evt, Object arg)
if (evt.target instanceof MenuItem)
               {System.out.println(evt.target);
if (arg == "Show")
dialog.show();
else if (evt.target instanceof Button)
{System.out.println(arg);
if (arg == "close")
dialog.hide();
System.out.println(evt.target);
return true;
regards

Your using JDK 1.2 or higher, right?
Change resize to setSize - resize was deprecated as of 1.1. Don't use action(Event, Object) - it was deprecated as of 1.1, too. To activate the close button, use addActionListener (see below). Add another action listener for your Show menu.
Button close = new Button("close");
// Add this code.
close.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Your code to handle the event.
dialog.hide();
dialog.dispose();
// End of new code.
dialog.add(close);

Similar Messages

  • How can a dialog box close itself?

    I have a dialog box which displays a little form for some extra information.  I have some non-standard buttons which are under my control.  The form is created as a view in a window which is launched by CREATE_WINDOW.
    I want the window to be able to close itself.  The concept is easy - get a ref to the window, then call close( ).
    But I cannot find a way to get a reference to the window from inside the window.
    Here is my current solution which I do not like, but it works.
    I create a context node 'POPUP' which has an attribute ME of type ref to if_wd_window.
    When I create the window, I do this:
    lo_window         = lo_window_manager->create_window( ... )
    lr_node = wd_context->get_child_node(   'POPUP'   ).
    lr_node->set_attribute( exporting name  = 'ME'
                                          value = lo_window ).
    lo_window->open( ).
    In the window, it gets ME out of the node, and does a lr_me->close( ).
    But there is a better way, right?  How does a dialog box close itself under program control?
    I should add that the dialog box is displaying a view from a used component, so POPUP is defined in the used component and mapped into the context of the using component. I don't think this changes the problem, though.

    Hi
    Try this following code in method of button you have created for popup i.e  method for example  ok,cancel etc in the view which you have emebedded in ur window for popup.
    Close the popup
      DATA:
        lo_api         TYPE REF TO if_wd_view_controller,
        lo_window_ctlr TYPE REF TO if_wd_window_controller,
        lo_popup       TYPE REF TO if_wd_window.
      lo_api         = wd_this->wd_get_api( ).
      lo_window_ctlr = lo_api->get_embedding_window_ctlr( ).
      lo_popup       = lo_window_ctlr->get_window( ).
      IF lo_popup IS BOUND.
        lo_popup->close( ).
      ENDIF.

  • How to close a popup using a function key in adf + Jquery

    Hello All,
    I want to display some error message using function key so I have used javascript function
    *function showText(event) {*
    var k = event.getKeyCode();
    *if (k == 115) {*
    ------------------------------------------CODE-------------------------------------------
    This is working fine on click of F4 it is invoking a popup and inside that popup in dialog it is showing some error messages. The property modal of dialog is true. So that user should not be able to navigate to main form until error message is closed.
    Now on click of F6 I want that error message to be closed. When I added af:clientListener on popup or dialog type="keyDown" is not available.
    So I thought using jquery for this. I have created a form.js file inside that I have written:
    *$(function first()*
    *               jQuery('*').bind('keydown', 'F6', function (evt){closePopup();evt.stopPropagation();return false;});*
    *function closePopup(){*
    *     alert("Do you want to close the error message");*
    I have also added jquery.hotkeys.js and jquery-latest.js file.
    My question here is How can i find that popup or dialog inside that jquery function and close it?
    On click of F6 I am getting that alert Do you want to close the error message but after that how can I find the popup or dialog and close it?
    I am new to jquery still I tried using some code:
    var dialog = event.getSource();
    var popup = dialog.findComponent("p1");
    popup.close();
    and
    var output1 = AdfUIComponent.findComponent("p1");
    output1.close();
    and
    curElm = document.activeElement;
    var frm = curElm.close();
    But none of them worked.
    Please help
    Thanks

    Hi,
    this whitepaper: http://www.oracle.com/technetwork/developer-tools/jdev/1-2011-javascript-302460.pdf has an example of registering keyboard keys on a global level (see page 36). So you would define a key to close dialogs in general. The paper also explains how to search and find components. Note that you should always work with the ADF Faces client side API and never against the generated markup or DOM (which in fact your code does)
    Frank

  • How to close the object after generation Excel file

    I have generated excel file. I save that file using "Save" button on dialog-box. After i go to menu navigation at that time i got javascript error.
    please give me the solution how to close objects after generating excel file.

    Hi,
    Pls don't forget to reward points and close the question if you find the answers useful.
    Eddy

  • Any way to see ICONS in Open and Close Dialog boxes?

    Is there any way to see ICONS in Open and Close Dialog boxes, instead of just lists of items names?
    I know you can preview one at a time, but I'd love to see all my artwork as picture icons, just as you can in a finder window.
    Windows does this, but not OSX that I know of. Is there a third party app that enables you to see icon view in the Open and Close Dialogs?

    Thank you Steve Jobs. I guess that feature has been added in Leopard. Now there really is nothing that I'll miss from Windoze.

  • How to close extended classic PO in ECC...

    Hi Friends...
    We are in SRM 7.02 and ECC 6.05 in Extended Classic Scenario. One PO had been created for 1 Quantity 3 years ago. There was no GR/IR document posted against that PO. Now that PO had been archieved from SRM. But still PO is available in ECC with open quantity and also its appearing in the open PO report. Now requester wanted, the PO to be closed in ECC and shouldnot appear in the open PO list.
    How to handle this situation.. How to close the extended classic PO in ECC at this scenario. As PO not available in SRM, we can not do anything from SRM side.
    Your inputs are appreciated....
    Regards
    Sivakumar Kandasamy

    Hi Sivakumar,
    If you mean how to archive PO in MM side, please refer to the following info:
    ====
    In ECC system, if you want to archive a MM PO, please use transaction
    SARA->archive object MM_EKKO.
    456129 FAQ: Archiving in purchasing
    401318 Archiving: Additional information
    ====
    If you want to delete this ECC PO, please use BAPI_PO_CHANGE and
    refer to the following test data:
    Parameters:    PURCHASEORDER      =  XXXXXXXXX
    Parameters:    POITEM
    PO_ITEM                        = 00010
    DELETE_IND                     = X
    Parameters:    POITEMX
    PO_ITEM                        = 00010
    PO_ITEMX                       = X
    DELETE_IND                     = X
    You also need to run BAPI_TRANSACTION_COMMIT after BAPI_PO_CHANGE for updating the change.
    Regards,
    Ivy

  • After the update I don't know how to close running apps? I recall double clicking the main button then hold one app until they begin a jiggling motion. But that no longer works.

    How do close running apps?

    You still double tap the home button and the apps are lined up across the screen. Swipe up on the app preview thumbnail - drag it up off of the screen - and that will close the app.

  • How to close iOS7 apps?

    Prior to iOS7 you simply double clicked the home button to show open Apps and you could then close them all down.  That doesn't seem to happen with iOS7.  Any idea how to close open Apps?
    ... The learning curve beings

    Thanks ...
    That's what I was trying, but I guess I was doing so to quickly.  Once I slowed down they finally moved.  Now ... if the former Apps wouldn't crash I'd be all set, ROFL.  Going to be a learning curve for the developers as well I think.
    So much to learn

  • Can anyone advise how to close apps on iPad with new iOS? I have multiple open and cannot close them.

    Can anyone advise how to close apps with the new iOS?  I have multiple open and cannot close them

    Double-tap on the Home button. You will see a preview of the app above the actual icon. Slide the preview up to kill it.
    Please get the iPhone User Guide (For iOS 7 Software)Sep 19, 2013 - 23 MB.

  • How to close sidebar under ios 8 in order to use the whole screen for reading?

    How to close sidebar under ios 8 so that i can have the full screen for reading?

    Sidebar where?
    In Safari?Tap on the Blue open book icon at the very top of the screen. There are two such icons, it is the one on top you want to tap to close the sidebar.

  • How to close email notifications to senders from HP eprintCenter?

    Hi,
    How to close email notifications to senders from HP eprintCenter?
    Thank you.

    Hi Jack7363,
    Welcome to the HP Support Forums. I gather that you would like to know how to turn off notifications from HP’s ePrintCenter.
    To better assist you, would you please supply some additional information:
    What make/model/product number of HP printer do you have? How Do I Find My Model Number or Product Number?
    How is the printer connected (USB cable, ethernet, or wireless)?
    Do you have an HP Connected account or HP ePrintCenter account?
    Are the emails coming [email protected]?
    Thank you.
    Regards,
    Happytohelp01
    Please click on the Thumbs Up on the right to say “Thanks” for helping!
    Please click “Accept as Solution ” on the post that solves your issue to help others find the solution.
    I work on behalf of HP

  • How to close apps on iPhone 4

    I tried everything it says from the web from pressing the hold button 2 times and bottom shows the apps but cannot get the minus sign or get them to wiggle like people say anyone know how to close apps like this. mINE DOES NOT WORK SUPPOSE TO GET A MINUS SIGN OR HOLD TO WIGGLE NO LUCK.

    Maybe a visual will help: https://sites.google.com/site/appleclubfhs/support/advice-and-articles/locking-o rientation

  • How to close goods receipt PO

    Hi All,
    We are using SAP 8.8
    how to close Goods Receipt PO that has been pulled to A/P Invoice with a partial amount of freight ?
    i.e.
    Our GRPO has freight 5000.
    On pressing COPY FROM button in A/P invoice we selected that GRPO
    On Pressing Customize button
    Items in the GRPO appear
    We selected all items and press next
    Freight appears
    We edited freight amount from 5000 to 3000 and pulled GRPO into invoice and saved.
    After this OUR GRPO and freight remains
    Guidance in this is really needed as we want to tally stock
    Thanks
    Malhaar

    Hi Malhaar......
    Does it happen all the time like this reversal of entry?
    Like how you tested in demo this kind of scenario I would suggest you to do this excercise too.
    So that you get knowledge about that and Today you are asking this doubt but after doing this excercise you will come to know the exact effect and next time you can suggest this to others if he has same problem and will become expert in SAP
    All the Best
    Regards,
    Rahul

  • HT1212 how to close apps if your phone is locked because you forgot the password

    I need to close "find my iphone" in order to restore my phone. I don't know how to close this app

    Go to a computer.  Use its internet browser to sign on at http://www.icloud.com
    Go to Find My iPhone there.  Click on your device and choose "Remove This Device".

  • How to close the detach popup on click of a button in the panel collection

    Hi,
    I'm using Jdeveloper 11.1.2.3.0.
    I have an af table surrounded by panel collection. There is a button on panel collection to commit the changes in the table.
    Clicked detach button to view the table in full browser.
    On click of Commit button, the detach popup is not closed. I have set partialSubmit of that button to false. Then also detach popup is not closed.
    Can anybody suggest me how to close the detach popup on click of a button in the toolbar.
    Thanks,
    Vinod

    Hi Frank,
    Thanks for your response. Popup is not closed.
    I tried this approach, when the view tree is navigated on the Detach, I see that the tree is same as if it is traversed on the page without detach.
    Printed client id and UI component class in the while loop, result is as below.
    r1:0:pc1:t3 class oracle.adf.view.rich.component.rich.layout.RichToolbar
    r1:0:pc1 class oracle.adf.view.rich.component.rich.output.RichPanelCollection
    r1:0:ph2 class oracle.adf.view.rich.component.rich.layout.RichPanelHeader
    r1:0:pgl1 class oracle.adf.view.rich.component.rich.layout.RichPanelGroupLayout
    r1 class oracle.adf.view.rich.component.rich.fragment.RichRegion
    pgl1 class oracle.adf.view.rich.component.rich.layout.RichPanelGroupLayout
    db2 class oracle.adf.view.rich.component.rich.layout.RichDecorativeBox
    db1 class oracle.adf.view.rich.component.rich.layout.RichDecorativeBox
    psl1 class oracle.adf.view.rich.component.rich.layout.RichPanelStretchLayout
    ps1 class oracle.adf.view.rich.component.rich.layout.RichPanelSplitter
    f1 class oracle.adf.view.rich.component.rich.RichForm
    Tried with setting partialsubmit property to false on the command button, still the popup is not closed and my Faces Message are shown behind the detach popup.
    Thanks,
    Vinod

Maybe you are looking for

  • Not able to generate report in AVDF 12.1

    Dear DBA's, I installed 12.1 database vault server on Linux and created agent on 11.2.0.1 on solaris. The host status is showing running. In Security Target > Monitoring > Audit Trail in this menu the collection status is showing stopped and i clicke

  • Design Premium CS4 stopped working: error 148:3

    I am using Adobe design premium CS4. It used to work well but recently it has stopped working and displaying error :148:3. I would appreciate if someone could help me to solve this issue. Thanks, Regards, Jag

  • Sysfader: iexplore.exe - Application Error in Forms 10g

    Hi, I am new to Oracle Forms 10g. When I tried to run the Form, it is giving me an Error saying that *"The Instruction at "0x06130b58" referenced memory at "0x00000054". The memory could not be "read".* I am unable to run any Form. Somebody help me o

  • "Type of file not supported" but previous timeline files OK

    Simply put, I have projects that I can open up and they display and edit the MTS files from my Panasonic camera fine.  yet, I cannot add any new MTS files or even import ones that are already in the timeline without it saying to me "Type of file not

  • Multi-language Restart Screen at  Startup???

    Hello, My MBP has started showing me the multilanguage 'You must restart your machine' screen every time I attempt to start it up. In the last week or so it has been taking much longer to start up and some weird things have been happening like it tak