I can't close my swing form ...

I have a JFrame swing GUI - how do I exit the app ?
How do I display a popup box with a message ? or question ?
thanks !
Craig

To close the frame, in the constructor, add:
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
System.exit(0);
To pop up a prompt, add this when you click, say, "Exit" from a menu or button:
int ans = JOptionPane.showConfirmDialog(this,"Do you want to exit the application?", "ExitDialog", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (ans == JOptionPane.YES_OPTION)     {
System.exit(0);
}

Similar Messages

  • Can we print a swing form

    hi,
    i have a question , i m making a windows based application in swings, can i print that form, reply at the earliest..
    thanks in advancee

    //or try this program, just execute it.
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.awt.BorderLayout;
    import java.awt.print.*;
    import java.awt.Dimension;
    class printtest extends JFrame implements Printable,ActionListener
    Component c;
    printtest()
    super("just test");
    setSize(300,150);
    setVisible(true);
    JPanel p1=new JPanel(new FlowLayout());
    JLabel l1=new JLabel("name");
    JTextField t1=new JTextField(10);
    JButton b1=new JButton("Print");
    b1.addActionListener(this);
    t1.setText("hai");
    p1.add(l1);
    p1.add(t1);
    p1.add(b1);
    add(p1);
    this.c=p1;
    public void actionPerformed(ActionEvent e)
    try
    print();
    catch (java.lang.Throwable exc)
    System.out.println("Printer
    Exception");
    public void print() throws java.awt.print.PrinterException {
    PrinterJob job = PrinterJob.getPrinterJob();
    PageFormat format = job.pageDialog(job.defaultPage());
    job.setPrintable(this,format);
    if ( job.printDialog())
    job.print();
    public int print(Graphics graphics, PageFormat pageFormat, int
    pageIndex) throws
    PrinterException {
    if (pageIndex > 0)
    return Printable.NO_SUCH_PAGE;
    Graphics2D g2 = (Graphics2D) graphics;
    g2.translate(pageFormat.getImageableX(),pageFormat.getImageableY());
    c.paint(g2);
    return Printable.PAGE_EXISTS;
    public static void main(String ar[])
    printtest t=new printtest();
    }

  • Can't close form

    HI,
    I've got a big application in forms 4.5 with Oracle 7 and Oracle 8i. I transform this application in Forms 6i, my application can run and the communication with the database is OK, but i can't close it (any form) this error system message appear immidiately
    ifrun60.exe - Image incorrecte (i'm french)
    the application or the dll :c:\WINNT\System32\user.exe is not a valid Windows picture. Virify with your installation floppy. (Sorry for my translation.)
    This message appear when i want to do an exit_form with this application by some function. The application test Bankapp run normally, and this message appear with an OS W2K or Win NT4 pack6. When i try to do an DO_KEY('EXIT_FORM') the application run with the CPU at 100 % and never stop. When i try to do an EXIT_FORM without passing to my function, the application do nothing.
    I don't know what to do.
    thanks for your help

    This forum is for general Oracle Forms questions. Please post your question in the General EBS Discussion forum. If you have a general Forms question, by all means, ask it here! ;-)
    As you are clearly working with the Oracle Enterprise Business Suite (EBS) you are going to want to become familiar with the Oracle Applications Documentation library. Select your EBS version and then scroll to the Standards section and review the following documents:
    <ul>
    <li>Oracle Applications Developer's Guide
    <li>Oracle Applications User Interface Standards for Forms-Based Products
    <li>Oracle Application Framework Personalization Guide
    </ul>
    Craig...

  • Can't Close A Form in C#

    I've tried the Close term by itself, where I get a little note that comes up saying "this closes the form."
    I've tried this.Close()
    I've tried Application.Exit()
    These are all commands I've given to a button to Exit my application and nothing works.  The button does nothing.

    If you call Close() (or this.Close()) inside a form then it will close the form.  If the form you close happens to be your main form (the one that was passed to Application.Run in your entry point) then the app will terminate.  Calling Application.Exit
    will cause the app to close as well.
    When a form is closed it raises the FormClosing event.  Anybody can hook into this event and prevent a form from closing so calling Close doesn't guarantee the form will close in this scenario but for the general case it works.
    It sounds like to me that your not actually executing the code that calls Close.  Put a breakpoint on the Close call and verify it is being hit.  If it isn't then you need to modify your code such that whatever method contains the call to Close
    is actually being called.  In most cases it is being done when you click a button so make sure you have hooked up your button's click handler to the button either programmatically or via the designer. 
    Michael Taylor
    http://blogs.msmvps.com/p3net

  • How can I close a category in the form central form without closing it as error?

    How can I close a category in the form central form without closing it as error?

    I'm still not sure I follow - let me see if this is right.  You want to have users signing up for something using a FormsCentral form and then when something is full you'd like that section to show as "Closed" or full so nobody else can sign up for that particular event/day/time?  If that is the goal FormsCentral does not have any logic to close certain portions of the form.
    Thanks,
    Josh

  • Infopath: Rules run before Code...So Can we close the form through Code?

    Hi,
    I have a form with a couple of buttons. Clicking on any of the buttons first executes the RULES and then jumps to execute the code in the FormCode.cs file for the button click event. However, if I have "Close the Form" as one of the Rules for the button, the code does not execute. So, is there a way that I can close my Infopath fom after executing the code instead of closing from the RULES? Also "The form has been closed" is the message which pops up after closing form through rules. Can we redirect to the form library instead of showing this message?
    I tried to execute everything through code in FormEvents_Submit. It works fine if I have a single submit button. But how would i differenciate if there are multiple buttons like Approve, Reject etc.
    Thanks !

    Hi Aanu,
    Thanks for the reply.The proposed solution in the thread is to use;
    this.Application.ActiveWindow.Close();
    or
    thisXDocument.View.Window.Close(true) in order to close the form.
    Both of them don't work when I try to use them in Visual Studio. It complains of a missing namespace.
    Did this approach work for anyone?

  • Problem in printing a java swing form

    Hi,
    Could anyone help me on how to set the page margings while I print a java swing form since it is taking a lot of space as margins in the top right top and bottom how do i do that. or is it that java can only print in the printable area or is there any way i can increase the scope of the printable area

    I used PrintRequestAttributeSet and set the margins to 0.5 on all four sides by creating an instance of MediaPrintableArea. By default, the margins on all sides comes up as 1.0 inch. Default paper size is LETTER (8.5 x 11).
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(new MediaPrintableArea(0.5f,0.5f,7.5f,10.0f,MediaPrintableArea.INCH);
    PrinterJob printJob = PrinterJob.getPrinterJob();
    printJob.setPrintable(component);
    if(printJob.printDialog(aset))
    printJob.print(aset);
    hope it helps.

  • Can't close a window in html or JS

    How can I close a "child" window opened from a "main" window in html or JS without resorting to asking the user to close the "child" browser window? I think I have tried just about everything. I have tried opening the "child" window by an tag and with JS. I can get the "child" window to open but cannot seem to return to the unchanged "main" page. I know I must be doing something wrong.

    <form> should be inside the body element.
    <html>
    <body onClick="window.close(self)">
    <form>
    Click here to return to entry form.
    </form>
    </body>
    </html>
    There's no immediate need for a <form> element. You can use a pseudo button. Simply give the visitor something to click on.
    BTW the browser "back" arrow is dimmed in the child window in IE, Firefox, and Safari.
    When a webpage is opened in a new window there's nothing to go back to.

  • Adf swing form login problem (Frank, look at this please)

    Hi All. I'm using JDeveloper 10.1.3
    Can anybody please give me a clue on how to create a simple stand alone adf swing form with a login dialog and the oracle jaas authentication?
    For me this kind af appllications works well only in design time :(. When i try to launch my generated .jar application the login dialog does appear but the authentication
    doesn't work "incorrect username or password".
    So i think i followed all the instructions from jDeveloper online help concerned with generating a login dialog... but my application still doesn't work properly after deployment.
    Please somebody look at what i've done and tell what is wrong.
    1. I created an adf swing form with a login dialog.
    2. I set the jbo.security.enforce property for my application module to Must.
    3. I added to my application a dialog for adding, removing and modifying application users via oracle.security.jazn api.
    4 I tested my appllication in Jdeveloper. It works great! I even added a number of application specific default users via my application.
    5. I assured myself that the oc4j security library has been added into the adf/swing project as well as into the deployment profile.
    6. I deployed my apllication to a .jar file.
    7. I created "config" folder inside the directory where the.jar file has been dropped. I copied there the following files: jazn.xml and system-jazn-data.xml (the last one file includes all my previously created principals) from /jdev_home/j2ee/home/config.
    8. Now when i start the application the login dialog appears as i've mentioned but authentication doesn't work.
    I found only one similar topic over the whole forum:
    http://kr.forums.oracle.com/forums/thread.jspa?threadID=665430
    but what i've done seems to meet all Frank's advices.....
    Oracle staff please dont ignore my post.
    Thanks in advance.
    Edited by: Timin on Jun 22, 2009 11:58 PM

    Hi, rob nice to learn that i'm not the only one stumbled over this issue.
    Hope that this question will be finally answered...
    ...just a few additional comments.
    1. It appears that the position of the jazn.xml and jazn-data.xml files pointed in the documentation (config subfolder of the root .jar's folder) is right for if i rename or delete the jazn.xml it runs into the error: jazn configuration file not found, but nevertheless it works strange, it looks like it doesn't use the mentioned files at all....given the fact the i've already spent a number of days experimenting and looking for a solution i learned that after a first startup the files mentioned above (jazn.xml and jazn-data.xml) are modified in some way that prevents using them on another oc4j server instance (if i have i.e. another jdeveloper instance, i cant run and go through authentication in my application by simply coping the old jazn.xml and system-jazn-data.xml files into the /jdev_home/j2ee/home/config
    folder...instead i need to copy a pure "initial" jazn.xml file from the initial jdeveloper archive) ... something like the thing mentioned here:
    http://radio.weblogs.com/0118231/stories/2007/05/08/jdeveloperadf11gTechnicalPreviewTipsAndTricks.html
    also i noticed that if there is no system-jazn-data.xml file in the config folder it is created automatically after a first startup...so when i tried to delete the system-jazn-data.xml file from my deployed application's folder it would't create a new one though it saw the jazn.xml file (since no "jazn configuration file not found" error had ever appeared)...i also tried to place "pure" copies of jazn configuration files in my config subfolder but of course it would give no effect.
    2. i also changed the login.module.provider as well as the auth.policy.provider properties in the java.security file as documentation sais - no effect.
    So it would be great if Frank gave us a direct link to the white paper he was working on (and i hope had finished :) few years ago....or even better gave me the simpliest example of a finished adf swing application with authentication implemented.
    [email protected]
    ps. we know it's really really time consuming answering all questions but considering the lack of documentation on adf swing technology i hope we can rely on your help here.
    thanks.

  • How to close a custom form from CUSTOM.pll

    Dear Friends,
    We need your help on the following issue related to Oracle Apps Forms.
    We have a requirement to show a popup message (message should remain open and user should be able to continue working in the order entry form. User use this message as a reference while entering order details) when user enters a customer name or number in the order entry form . This is similar to the Stock Availability form which gets opened automatically when control enters into Order Entry Lines form, where the stock availability form remains open while entering line details.
    To fullfil the requirement, we have designed a custom form with a single text field in which the message text (some customer information) will be shown.
    We are using custom.pll to call this custom form (thru FND_FUNCTION.EXECUTE) when the control leaves customer number field. User could leave this custom form open and continue with entering order details. Till this point we could achieve what we want. i.e. we could show the popup message in the custom form after user enters a customer number.
    The problem is, after the custom form is opened, when we enter a new order for different customer, we need to close the custom form (which is opened for the previous customer) if the customer is not qualified.
    we could not achieve this. We tried using CLOSE_FORM, CLOSE_WINDOW, but did not help.
    Any body have any suggestions on achieving this... Basically, we need your help to know how we can close the custom form from CUSTOM.pll.
    Thanks,
    Uma

    I thing you haven't any (supported) option to close a form via custom.pll.
    For a long time, we have search a solution for the same problem without any result.

  • How can i close a modal window?

    Hi, everybody
    My question is in the subject, but i4ll repeat it again.
    How can i close a modal window in forms?. I4ve tried with hide_window but it doesnt closed itself.
    Please help me one again.
    Thanks.
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by JAMIE MCPHIE ([email protected]):
    There is a bug with Oracle Forms where you can not use the close button "X" on the window title bar. You need to create a button on the window that will close the form.<HR></BLOCKQUOTE>
    Jamie
    You are right in the fact of the programmer must make a exit mechanism. However, this is not a bug, this feature is related to the management of this windows type (modal). Bye
    null

  • How to embed/perform a Java Swing form into webased Swing form

    How to embed/perform a Java Swing form into webased Swing form or any alternative.
    Suppose i have 2 or more swing forms which are desktop applications but i want those forms to be now webbased..so how can i do this.Will i need to change the swing coding or will have to keep the swing design same.what can be the best Solution.

    You can launch your existing desktop app via the web using [Java Web Start|http://java.sun.com/javase/technologies/desktop/javawebstart/index.jsp]

  • ADF swing forms and panels developer documentation

    Can anyone recommend me a ADF swing forms and panels documentation or tutorials?
    Thanks in advance.

    Good question cherem.
    Last I heard ... "its not available and still a plan":
    ADF Swing follow-on developer's guide
    regards
    Jan Vervecken

  • Unable to refresh parent swing  form components after returning from child

    Hi,
    Not able to refresh the parent swing form components after returning from the child form.
    I am having problem in setting/resettig values to the parant swing form components after returning from child form. In parent form, I am entering values in some of the fields and clicking on Search button in parent form which will open a child window with the search results in JTable. Now selecting a row and writing the selected data to an ArrayList and returning back to the parent. I am able to see the values in the ArrayList, but not able to set any value to any of the parent form components by using the formtextfield.setText("value").
    Thanks
    Yakshak

    create another project
    a frame with a formattedTextfiled and a button
    the button to open a child window
    in the child window use say a JTextField to simulate a search result (type in some dummy data)
    now add the arraylist code that produces the problem
    if this stripped-down version of your program has the same problem, post all of the stripped-down code,
    so we can see what you're doing.

  • I can't close find my iphone

    i can't close find my iphone what i do ?
    help me please

    do you own the Apple ID to which the device is locked in Find my iPhone?  If you do not own it, you cannot unlock it without knowing the former owner's Apple ID and password or having him remove the iPhone from his account.
    Read this document:
    http://support.apple.com/kb/PH2702?viewlocale=en_US

Maybe you are looking for

  • How can I send an image directly from the browser as an attachment, not a link?

    I'm wondering if there's a way-- either via some kind of add-on or a direct FF customization-- to send an image as an attachment rather than as a link? either right-clicking an image and selecting "send image" or dragging an image into a "new message

  • Changes to sapxmltoolkit.jar from PI7.0 to PI7.1

    Hi. This question is about "XSLT Mapping with Java Enhancement". We have build numerous interfaces that uses java functions in a XSL mapping. This works fine in PI7.0, but when porting to PI7.1 it stops to work. SAP gives examples how to make this wo

  • How to change the row position in a datatable

    I am storing my list of lists in a datatable : DataTable table = new DataTable(); for(int i = 0; i < info.Count; i++) table.Columns.Add(names[i]); for(int col = 0; col < info.Count; col++) for(int rows = 0; rows < info[col].Count; rows++) DataRow r =

  • MB 2.4 or "old" MBP 2.5 ... same price?

    I need to purchase a new Mac laptop for my 14-year old daughter. She would love the MB but the former top of the line MBP is basically at the same price at Amazon. What is the sensible thing to do? Old screen better, more expansion, speed similar (ri

  • Merge two full-screened safari windows' bug under lion

    Hi there, After installed lion, i found an obviously bug in safari. 1. Open safari, enter full-screen mode. 2. Creat a new safari window (not a new tab), then it will moved into a other full-screen automaticlly. 3. Click in menu bar : window>merge al