Program not exiting when dispose() used.

pl see the code.
I am unable exit the window if the new class Ex() is defined.
No error displayed, while running the program. What is the mistake. If anyone see please inform. No compilation error and at runtime, if Exit button is pressed, the window is not getting closed. I want to use dispose() instead of System.exit(0).
This is because, If I use System.exit(0), my menu program would also get disconnected.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import java.io.*;
class ts extends JFrame
JPanel jpn1,jpn2,jpn3;
JButton b1,b2,b3;
JLabel jlh;
JFrame fr;
Container cp;
Connection con = null;
Choice ch1,ch2;
public ts()
final JFrame jf = new JFrame();
JPanel jpn1 = new JPanel();
jpn1.setLayout(null);
jpn1.setBackground(Color.pink);
jpn1.setPreferredSize(new Dimension(800,100));
JPanel jpn2 = new JPanel(new GridLayout(0,1));
jpn2.setPreferredSize(new Dimension(775,50));
jpn2.setBackground(Color.cyan);
jlh = new JLabel("Test Module",JLabel.CENTER);
jlh.setFont(new Font("TimesRoman",Font.BOLD,25));
jpn2.add(jlh);
JPanel jpn3 = new JPanel();
jpn3.setBackground(Color.yellow);
jpn3.setPreferredSize(new Dimension(800,50));
Container cp = jf.getContentPane();
cp.add(jpn1,BorderLayout.WEST);
cp.add(jpn2,BorderLayout.NORTH);
cp.add(jpn3,BorderLayout.SOUTH);
JButton b1 = new JButton("Get Details");
b1.setBounds(150,450,100,20);
jpn1.add(b1);
JButton b2 = new JButton("Update");
b2.setBounds(300,450,100,20);
jpn1.add(b2);
JButton b3 = new JButton("Exit");
b3.setBounds(450,450,100,20);
jpn1.add(b3);
b3.addActionListener(new Ex());
/* b3.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
jf.dispose();
return;
//System.exit(0);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setSize(800,700);
jf.setVisible(true);
//jf.pack();
jf.show();
class Ex implements ActionListener
public void actionPerformed(ActionEvent evt)
if(evt.getSource() == b3)
dispose();
return;
public static void main(String[] args)
new ts();
}

Your class both extends JFrame and instantiates a (separate, totally different!) JFrame. You are disposing the wrong JFrame -- and there shouldn't be two anyhow.
Since you are not modifying any default behavior of JFrame, your class has no reason to subclass JFrame. Always prefer composition over inheritance.
In future (not this time), Swing questions should be posted in the [Swing forum|http://forums.sun.com/forum.jspa?forumID=57]
db
edit And go through the [Swing Tutorial|http://java.sun.com/docs/books/tutorial/uiswing/index.html] which will (hopefully) raise your level of competence. You need more inputs than a forum can provide.
Edited by: Darryl.Burke

Similar Messages

  • CRM 7.0 upgrade ( i5/OS PASE program not found or in use)

    Hi,
    We are upgrading CRM 5.0 to CRM 7.0 on iSeries (V6r1) and facing the following issue.
    When I execute this command
       STARTUP    SID(CD3)  TYPE(ABAP)  RESTART(YES)  DVDPATH('/Inst_DVDs/51036889')
            SAPUPLIB(SAPUP)  OPTIONS('jce_policy_zip=/Inst_DVDs/51036889/local_policy.jar')
    iSeries show this error message in "UPG_A_CD3" job log.
       Message . . . . :   i5/OS PASE program not found or in use. Path name is
           /usr/sap/CD3/upg/STARTUP.                                             
    Does anyone has any idea what could be wrong ?
    Thank you,
    Jack.

    Hi,
    We are upgrading CRM 5.0 to CRM 7.0 on iSeries (V6r1) and facing the following issue.
    When I execute this command
       STARTUP    SID(CD3)  TYPE(ABAP)  RESTART(YES)  DVDPATH('/Inst_DVDs/51036889')
            SAPUPLIB(SAPUP)  OPTIONS('jce_policy_zip=/Inst_DVDs/51036889/local_policy.jar')
    iSeries show this error message in "UPG_A_CD3" job log.
       Message . . . . :   i5/OS PASE program not found or in use. Path name is
           /usr/sap/CD3/upg/STARTUP.                                             
    Does anyone has any idea what could be wrong ?
    Thank you,
    Jack.

  • I have a 17" Macbook pro with flickering red and cyan(blue) lines across the screen. The issue disappears temporarily when I tap on the computer, and the problem does not occur when I use external display or try to screen capture the problem.

    I purchased my Macbook (17") through a certified apple tecnition in August 2012, it was refurbished and the motherboard was completely replaced. I do a lot of photo editing, but I have been unable to do so because of the red vibrating lines that interrupt my screen. The issue disappears temporarily when I tap on the computer, and the problem does not occur when I use external display or try to screen capture the problem. I brought the computer back to the technition I purchased it from and he said that it was a problem with my fan, so I have two new fans but the issue is still occuring. He says he doesnt know whats wrong. Does anyone have any information on this issue?
    Here is an image of the issue
    http://www.flickr.com/photos/67839707@N08/8884847081/

    I recommend having your Mac serviced by someone competent. A force sufficient to "blow apart" the fans was clearly excessive and may have damaged the display cable, as well as any number of other problems.
    Dust is properly cleaned with a vacuum, preferably one designed for computer service, and they are not cheap.
    Compressed air should never be used. It just blows dust everywhere, often into places where it can no longer be removed.

  • Acrobat Pro is now constantly giving me the error message (program not responding) when I try and perform any kind of action.

    Acrobat Pro is now constantly giving me the error message (program not responding) when I try and perform any kind of action.

    Hi cruzsanta03,
    Can you please let us know the following:
    - Operating System;
    - Complete version of Acrobat installed;
    - Experiencing this issue with a particular file or all PDF files;
    - Experiencing this issue while performing a particular task or with any task;
    - Files are saved on the local machine or on a share drive;
    - Launch Acrobat in Safe Mode and then check the issue. Hold 'Shift' key and launch Acrobat, and then check the issue.

  • Red Hat Enterprise Linux Test Page - why am I directed to this page when I go to a specific website. It does not happen when I use other browsers so there is not a problem with the website.

    Red Hat Enterprise Linux Test Page - why am I directed to this page when I go to a specific website. It does not happen when I use other browsers so there is not a problem with the website.
    Just started happening yesterday.

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"
    Do you see any prefs related to that <b>knoxnews<i></i>.com</b> site on the <b>about:config</b> page if you enter that URL in the Filter?
    *http://kb.mozillazine.org/about:config
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • I have a folder with 10 folders inside it, 8 of the folders will not function when I use "show view options".

    I have a Folder with 10 Folders inside it, 8 of the Folders will not function when I use "show view options", they always default back the default.  The "show view options" works on all my other Folders in my system, even on the first two of the Folder in question.  How can I correct it?  I have tried every thing I can think of, even deleting the Folders & reintalling them.  For some strange reason the "show view options" only does not work on the last 8 Folders in the Folder in question.

    Instead GarageBand recognize my keyboard and i can play normally, also, if it can help, those are the Audio and Midi Logic Preferences and the Controller Surfaces Setup with the keyboard connected :

  • My iphone 4 ,new update give me not happie ,when i use yahoo messenger little whow there freeze my phone

    my iphone 4 ,new update give me not happie ,when i use yahoo messenger freeze

    Basic troubleshooting from the User's Guide is reset, reset, restore (first from backup then as new).  Try each of these in order until the issue is resolved.

  • JVM not exiting when program terminates

    I am developing an application that uses Frames on a pocket PC. At some certain event, I call System.Exit to close my application. However, doing this does not shutdown the JVM. Is there a way to force the JVM to exit?

    Are you using j9.exe or j9w.exe to run your code? j9.exe launches a console which does not exit until the user closes it, otherwise you wouldn't be able to see your stdout after your application terminated. j9w.exe does not launch the console window.

  • [SOLVED] Autostarted programs not exiting on logout with openbox

    Hi,
    I'm pretty sure I'm just overlooking something obvious, but I simply can't find a solution to the following basic problem. I'm using a simple openbox session started from xdm (also tried lightdm with the same results). In case of xdm, I'm using a .xsession file to start openbox like this:
    exec dbus-launch --exit-with-session openbox-session
    In case of lightdm, it also works without a .xsession or .xinitrc file.
    I'm using "~/.config/openbox/autostart" to start some tools upon login. Until now, I have only started programs which exit right away which worked fine. But now I'd like to use autostart to start a (non-X11) program which should continue to run until I log out. For testing this, I used a simple infinite loop script, let's call it "loop.sh". When I start loop.sh in autostart using "loop.sh &", this script continues to run even if I log out of openbox using the openbox menu. In fact, if I log out and log in multiple times, multiple instances will keep running forever. When I start loop.sh simply using "loop.sh", also the parent processes, namely "/bin/sh /usr/lib/openbox/openbox-autostart OPENBOX" and "sh /home/ochi/.config/openbox/autostart" continue to run.
    What is the correct way to have all processes spawned during the X session killed upon logout?
    For reference, this is the loop script I use:
    #!/bin/bash
    while true; do
    # If you like, you can also play a sound for feedback.
    #paplay /usr/share/sounds/freedesktop/stereo/complete.oga &
    sleep 1
    done
    Update: Using gdm seems to "fix" the problem, i.e. all programs started by the autostart script seem to get killed correctly. However, gdm pulls a LOT of dependencies I don't want to have. I wonder what gdm does differently...
    Last edited by Ochi (2015-04-18 23:38:21)

    I continued to study this subject, and here is what I found at this time.
    First I precise again that I use openbox launched by startx at login in tty.
    When I exit openbox, I return to a -bash prompt, and I then can log out of tty.
    After logging in into openbox, I have:
    └─user.slice
    └─user-1000.slice
    ├─[email protected]
    │ ├─1421 /usr/lib/systemd/systemd --user
    │ └─1422 (sd-pam)
    └─session-c1.scope
    ├─1414 login -- berbae
    ├─1425 -bash
    ├─1432 /bin/sh /usr/bin/startx
    ├─1454 xinit /home/berbae/.xinitrc -- /etc/X11/xinit/xserverrc :0 vt1 -auth /tmp/serverauth.xxxxxxxxxx
    ├─1455 /usr/lib/xorg-server/Xorg -nolisten tcp :0 vt1 -auth /tmp/serverauth.xxxxxxxxxx
    ├─1459 /usr/bin/openbox --startup /usr/lib/openbox/openbox-autostart OPENBOX
    ├─1464 dbus-launch --sh-syntax --exit-with-session
    ├─1465 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
    etc...
    When I exit openbox, without logging out, I have:
    └─user.slice
    └─user-1000.slice
    ├─[email protected]
    │ ├─1421 /usr/lib/systemd/systemd --user
    │ └─1422 (sd-pam)
    └─session-c1.scope
    ├─1414 login -- berbae
    └─1425 -bash
    If I ran something in background from konsole, when in openbox, this is not killed:
    └─user.slice
    └─user-1000.slice
    ├─[email protected]
    │ ├─1421 /usr/lib/systemd/systemd --user
    │ └─1422 (sd-pam)
    └─session-c1.scope
    ├─1414 login -- berbae
    ├─1425 -bash
    ├─1296 /bin/bash /home/berbae/bin/loop.sh
    └─1338 sleep 60
    If I log out, the process is still not killed!
    └─user.slice
    ├─user-1000.slice
    │ ├─[email protected]
    │ │ ├─517 /usr/lib/systemd/systemd --user
    │ │ └─519 (sd-pam)
    │ └─session-c1.scope
    │ ├─1296 /bin/bash /home/berbae/bin/loop.sh
    │ └─1338 sleep 60
    As seen the '[email protected]' with the 'systemd --user' process is not ended too, even after logging out.
    Edit: This is due to the session c1 still active; see next post.
    I don't know if this is intentional, maybe it is a feature.
    Now I found and propose a way to change this apparently default behavior, if it is not wanted.
    First to end the 'systemd --user' process at logout, it is easy; just run:
    $ systemctl --user enable exit.target
    Edit: This is useless, sorry; see next post
    Then to run a process in background, which should end when logging out, just launch it like this:
    $ systemd-run --user loop.sh
    This will launch the command 'loop.sh' as a service in the 'systemd --user' manager, instead of the 'session-c1.scope';
    and it will be ended at logout, because the manager is now ended at logout, with the normal end of the manager.
    Edit: see next post
    I will continue studying this matter, to see if something else interesting can be found.
    Edit: See the 'Edit:' lines above for the modifications, before the explanations in the next post.
    Last edited by berbae (2015-04-16 14:38:35)

  • Program not working when transfered to a mobilphone.

    Hi all.
    I have made a program that should be able to send a message over bluetooth.
    The program works when I use the simulator, but it cannot find any other devices, when I transfer it to the phone.
    Does any of you know if there are any special things that I should do to allow it to find other bluetooth devices on my phone.
    Hope you can help med here.
    Thx in advance.
    Kind regards Michael.

    Is the simulator correctly set to represent the phone you're trying to deploy on?
    Not all Java-enabled phones implement all Java functionality -- you should check to see that the phone implements the correct JSR (I believe it's JSR-82).

  • PL/SQL program not working when connect database via SqlNet

    Hi,
    This is a segment of a PL/SQL program before opening a cursor using input descriptor. It is working fine ( to get the value of unOutputCount ) without connect to a database via SqlNet, can anyone tell me why it is not working ( unOutputCount return 0)while connecting to a database via SqlNet and how to make it work without opening a cursor before DESCRIBE OUTPUT ...?
    EXEC SQL ALLOCATE DESCRIPTOR GLOBAL 'input_111'
    WITH MAX 100;
    EXEC SQL ALLOCATE DESCRIPTOR GLOBAL 'output_111'
    WITH MAX 100;
    EXEC SQL PREPARE STMT1 FROM :psSqlStatement;
    EXEC SQL DECLARE CURSOR1 CURSOR FOR STMT1;
    EXEC SQL DESCRIBE INPUT STMT1
    USING DESCRIPTOR GLOBAL 'input_111';
    /* Get count of input parameters in statement */
    EXEC SQL GET DESCRIPTOR GLOBAL 'input_111' :unInputCount = COUNT;
    EXEC SQL DESCRIBE OUTPUT STMT1
    USING DESCRIPTOR GLOBAL 'output_111';
    /* Get count of output parameters in statement */
    EXEC SQL GET DESCRIPTOR GLOBAL 'output_111'
    :unOutputCount = COUNT;

    Hi,
    Welcome to Oracle OTN Forums!
    I changed your code a little. I think this help you
    CREATE OR REPLACE
    PROCEDURE xx_test
    IS
      v_pid VARCHAR2(100);
      v_cn  VARCHAR2(100);
      v_id  VARCHAR2(1000);
      v_val VARCHAR2(1000);
      CURSOR C1
      IS
        (SELECT product_id, 'PRODUCT_ID'  cn
            FROM product1 );
      BEGIN
        FOR V1 IN C1
        LOOP
          FETCH C1 INTO v_pid, v_cn;
          dbms_output.put_line('==== '||v_pid||'==== '||v_cn);
          EXECUTE IMMEDIATE
          'SELECT product_id, DECODE(COUNT (product_id),1,MAX (product_id))||'''||V_CN||''' as val
            FROM product1
           WHERE product_id =:a
           GROUP BY product_id)' INTO v_id, v_val USING v_pid;
          dbms_output.put_line('==== '||v_id||'==== '||v_val);
          EXECUTE IMMEDIATE 'UPDATE product2 SET '||v_cn||' = ' ||''''|| v_val ||''''|| ' WHERE product_id = :b' USING v_pid;
          dbms_output.put_line('++++ '||v_cn||'++++ '||v_val||'++++ '||v_pid);
        END LOOP;
      END xx_test;

  • I have been organizing my bookmarks into folders. There are a bunch of bookmarks that appear on the Bookmarks Menu that do not appear when I used the Organize Bookmarks option. Therefore I can't organize them. How do I get at them and move them to folders

    I used Organize Bookmarks to put some bookmarks in folders. When I had done all the bookmarks that appeared outside of folders in the Organize Bookmarks window, I closed it and looked at my bookmarks menu. Under my folders were some other bookmarks that I hadn't seen in Organize Bookmarks and when I used it again, they still weren't visible. Therefore, I couldn't move them into folders.

    Update - I discovered that the entire list of bookmarks can be accessed in the Organize Bookmarks window by clicking on the icon for Bookmarks Menu.
    This seem like odd interface behaviour to me.
    All the other software I use follows the pattern that an icon with a triangle to the left, which you click on to expand the menu tree downwards, shows the entire contents of the category when you click on the triangle. In other words, you don't get a different response by clicking on the icon from what you get by clicking on the triangle.
    It also seems odd to me that when an unsorted bookmarks folder is automatically provided that unsorted bookmarks would not be placed there by default.
    Anyway, by getting the list of bookmarks displayed this way I was able to simply right-click on items in the list and delete them, as I thought I should be able to do. Problem solved. Organize Bookmarks interface found to be somewhat unintuitive.

  • Scroll bar does not slide when dragged using curser in word

    I need answers to two questions.
    1.   How to maximise a word document to full window size.
    2.   Why the side scroll bar of a document does not slide when dragged.
    3.   Am very  used to the "delete", "page up and page down" keys and cant find them on keyboard.
    Thanks.

    What you can try if the above doesn't work, is deleting the scroll bar from your Data List, and then dropping it back in from the Library. The act of re-adding the scrollbar may get you the desired behavior.
    If that doesn't work, you will probably need to post your project so we can take a look.
    -Bear

  • IIS service not showing when I use the get-exchangeCertificate | fl cmdlet

    Hello All,
    I just installed a 3rd party digital certificate to my Exchange 2010 via powershell then assigned the 4 services IIS, pop, smtp, imap but when I use the get-exchangecertificate | fl cmdlet the IIS service is not showing.The rest of the services were fine. 
    During the process of installing the certificate via powershell, I got a message that says: Do you want to enforce SSL communication on the root web
    site? If not, rerun the cmdlet with the -DoNotRequireSSL parameter. I said No to all and the operation continued. By the way, I also invoke the iisreset /restart right after installing the digital
    certificate. I then proceeded to install my root certificate and intermediate certificates. All were imported successfully via certificate snap-in. When I access the exchange 2010 EMC console, the status for the Exchange Certificate still says pending certificate
    signing request. Not sure if that is related at all to the fact that IIS service is not showing amongst the assigned services listed. Any idea why IIS service is not in the list of assigned services for Exchange certificate?? Can I re-run my powershell and
    repeat my steps, but this time just assigned IIS service alone? Or should I re-run powershell altogether and assign all 4 services again??? Also, what about the pending certificate signing request in the EMC console should I process and complete the request??
    Any advise is appreciated. Let me know please.
    Thanks!
    Lotusmail1
    Franz Garcia

    Hi Lotusmail1,
    Please run the following command to just assign IIS service to this third-party certificate (using certificate 5113ae0233a72fccb75b1d0198628675333d010e as a example), then run Get-ExchangeCertificate to check it again:
    Enable-ExchangeCertificate -Thumbprint 5113ae0233a72fccb75b1d0198628675333d010e -Services IMAP,POP,IIS,SMTP
    Regards,
    Winnie Liang
    TechNet Community Support

  • APPS Adapter / Business Events not visible when BPEL uses non-apps user

    We have BPEL connection using custom oracle user, xx_b2b and when we use APPS adapter in BPEL, I can not see and use any business event.
    If anybody across same requirement, please share your experience.
    Appreciate help on this.
    Thanks,
    Sonartori

    Hi,
    I'm facing the same issue. Were you able to resolve it. Appreciate if you can let me know.
    Thanks
    -Prapoorna

Maybe you are looking for