JFileChooser doesn't close?

Hi All,
I'm working on an application which has a button actionlistener that calls a method to open a file using FileChooser. I can click the button and get the filechooser dialog box and select a file, but then the filechooser seems to be repeating - it pops up again!
Am I missing something? One click = one action, right?
Confused....
Here's the code:
     // Action Listener methods
     public void actionPerformed(ActionEvent event)
          if(event.getSource()==btnExit) {
               if(brInFile!=null)
                    try
                         brInFile.close();
                    catch(IOException ioe) {}
               System.exit(0);
          else if(event.getSource()==btnOpenInputFile) {
               readInFile();
     public void readInFile()
          String strInFile = "";
          JFileChooser jfc = new JFileChooser();
          if(jfc.showOpenDialog(this)!=JFileChooser.CANCEL_OPTION)
               try
                    brInFile = new BufferedReader(new FileReader(jfc.getSelectedFile()));
               catch(FileNotFoundException fnfe)
                    JOptionPane.showMessageDialog(this,"File Not Found!");
     }

Well, the code you posted gives no clues as to why this is occurring. One possibility is that you are adding the same listener to the Button twice. This would cause the problem you are getting. Try inserting a line to print out all of the listeners registered with the button when the actionPerformed method is invoked.

Similar Messages

  • Firefox did an automatic update to 6.01, and now my middle mouse button is not working in the browser. It doesn't close tabs, it doesn't open new tabs by middle clicking a link, it doesn't allow me to middle click to scroll the page...

    Firefox did an automatic update to 6.01, and now my middle mouse button is not working in the browser. It doesn't close tabs, it doesn't open new tabs by middle clicking a link, it doesn't allow me to middle click to scroll the page..

    [BUG FIXED, see "EDIT 2" at the end of my post]
    I'm on Firefox 3.6.21, and I got this problem today after a Greasemonkey update (To version 0.9.10, apparently).
    Disabling Greasemonkey solved the problem, and re-enabling it reproduced the problem (middle-clicking links to open in new tab did not work, merely highlighted the link).
    I should also note that while Greasemonkey was enabled and the bug was affecting me, Ctrl+Click to open links in new tabs was also broken.
    I hope this helps!
    EDIT: It appears this is a known incompatibility/conflict bug between current versions of Greasemonkey and Tab Mix Plus. Read more here:
    https://github.com/greasemonkey/greasemonkey/issues/1406
    EDIT 2: GREASEMONKEY HAS NOW BEEN UPDATED with a workaround to fix the problem. Go to https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/versions/ to install the update manually. It hasn't been reviewed by Mozilla yet, so it won't be an automatic update for another day or two. All credit to "cannonfodder" below for noticing this; please mark his post as helpful!

  • Is there some way to add multiple addresses to an email I am sending that doesn't close the contact list after I click on an address?  This necessitates constantly going back to click the + sign to add each address separately.

    Is there some way to add multiple addresses to an email I am sending that doesn't close the contact list after I click on an address?  This necessitates constantly going back to click the + sign to add each address separately.  Is there some way I can open the contact list, click on all of the individual addresses to which I want to send the email without the list closing between each address entry, and have all of my address entries be listed to the email at one time?  Something like it works in Gmail.  I do not want to use set lists, I want to enter different addresses each time I send an email.  And I am a very slow typist, so I don't want to type the first few letters of each recipient's name.  It is much faster for me to just click on the e-mail addresses in the list as a group.  It doesn't make any sense to me to have to reopen the contact list for each address, when it should be so easy to click on all of the addresses I want at one time and then click once to add them all to the email as a group.  If there is a solution to this, please tell me.  Thanks.

    Vatlily,
    Try this:
    1. Select Mail>File>New Message.
    2. Select Mail>Window>Address Panel.
    3. Use (command+click) on the desired addressees in the Address Panel to create the list.
    4. Click "To:" on the top left of the Address Panel.
    The group that you selected will be added to the "To" field in your New Message.

  • JOptionPane doesn't close

    Hi,
    I've a problem with a JOptionPane.
    This is my code:
    public class myFrame extends JInternalFrame {
       private JInternalFrame parent = null;
       public myFrame(){
          parent = this;
       jComboBox().addItemListener(new java.awt.event.ItemListener() {
                   public void itemStateChanged(java.awt.event.ItemEvent e) {
                               Object[] obj = {"MyQuestion?"};
                                int result = JOptionPane.showInternalConfirmDialog(parent, obj,
                                                      "Question",0,3);
                               if(result == 0){
    }The problem is When I change the state of the jComboBox component, the internal confirm dialog appears;
    but when I click on the "Yes" option (or on the "No" one), nothing happen;
    the confirm dialog hangs and I cannot do anything more, only stop the process.
    I've used, in the same program, in the same way, an internal confirm Dialog on an Action Event, and it works fine.
    Any ideas?
    Thank you in advance
    MargNat

    HI,
    now I'm partially solved the problem;
    That is:
    I've noticed if I cancel, in my prog, the listener jInternalFrame_Activated, the internal confirm dialog works, but not fine.
    Infact, when the event happen, it appears;
    then if I click yes, it disappear and all works fine;
    if I click No, it doesn't close; but if I click again on No, it close.
    I think it run twice the itemStateChanged relative code, but I don't know why.
    It seems the jComboBox is focused twice when I click twice on "No" option.
    Ideas?
    Thank you in advance
    MargNat

  • LaserJet 500 color M551 - tray 2 doesn't close

    I don't quite know the circumstances that lead to this happening, but looks like, all the sudden, tray 2 just wouldn't close. Just about when it should close, i feel some resistance maybe from the back of the tray, but not sure. I spent quite some time looking for any clues, such as anything bent, broken, warped, etc, but found nothing. Tried a lot of things, including resets and whatnot, but nothing worked.So i tried something that, right now, i know i shouldn't have; i got the tray from another M551 here at the office, just to see if it was something with the tray, and now... the tray on the other one ALSO doesn't close.  There was no forcing, bending, slamming, nothing like that. Just brough the tray over, put it in, saw it wouldn't close, brought it back, and it wouldn't close on the original, none of the trays do on any of the 2 printers.What's going on with these things???

    Found a temporary fix... that includes removing a partThis is being caused by the lock not engaging properly. I have no idea what the designation for any of these parts is, i'll just make things up and hope they make any sense.There is a guide with a pin on back of the tray , that goes into the lock. I would assume that, once the pin touches the lock, the lock would "pull" the tray in, that's how it seemed to work. The way it's happening right now, the lock is still engaging but not pulling the tray in, causing an obstruction that won't let the tray close. It's possible to manually arm the lock by pushing a tab nearby, tried multiple times, but i couldn't get it to sync. So i just removed the pin from the guide on the tray, and that bypasses the lock. Now the tray closes and the printer functions properly, it just behaves like trays without lock.  Not ideal, but as long as it works i'm fine with it. May not be a bad solution actually, just as "preventive measure" - one less things to malfunction.If someone knows how to fix, reset or whatever needs to be done to the lock, i'd still like to know\o  

  • [SOLVED] Closing Openbox doesn't close X

    Hey guys, I'm not sure if this is specifically a [testing] problem or not, but:
    Whenever I close openbox or run openbox restart, it drops me to a simple x session with no window management and doesn't close X. As a result of this, I've had no way to restart openbox without rebooting my computer completely.
    CTRL+ALT+F1 and CTRL+C doesn't work, as it did in the past, since it seems X now starts on VT1, which I think is a side-effect of systemd but I'm not sure.
    If anyone has experienced this, or has advice on how to restore this behavior to normal, I would appreciate it.
    Last edited by ndt (2012-11-02 18:29:33)

    I see exactly the same problem. It appears that 'openbox --exit' kills the WM, but does not fully exit openbox, hence the session remains. In my logout script, I now need an extra line after the exit, eg. 'openbox --exit; pkill -9 openbox'.
    The issue also affects oblogout.
    [EDIT}: I didn't notice that this is on [testing]. I do not use testing. This affects me on non-testing repos. I noticed it today (Oct 30).
    Last edited by mervinb (2012-11-01 02:08:08)

  • Download connections doesn't close after I cancel the download, it keep like I am download and only close when I disable the network adapter or reset the router or the firewall

    download connections doesn't close after I cancel the download, it keep like I am downloading and only close when I disable the network adapter or reset the router or the firewall.
    I use pfsense as my firewall and see the traffic not reseting to zero when I cancel download.
    Also, IE doesn't have this problem. When I cancel the download the traffic drops to zero.

    And this problem seems to be systemwide. Since I created a new user and under which problem still exists.
    Hope apple will look into it

  • Spotlight preview window often doesn't close

    OSX10.5. Spotlight. preview window in the spotlight search results column opens normally, but sometimes doesn't close. just sits there on top of all desktop items. So far the only way to get rid of it is to restart which is  a pain. Any thoughts?

    I am having the same problem: iTunes hangs when I try to quit. I haven't noticed it hanging at any other time, just when I try to quit. However, it also takes an extremely long time (one to three minutes) to start up and will sometimes quit in the middle of starting up. I am wondering if I have corrupted song files or something in my library? Or a corrupted plist file? Anybody have any ideas?
    I did just transfer this library from a G4 Mac running iLife '06 to the new MacBook Pro running iLife '09. Is there some incompatible file that didn't get updated, perhaps?

  • Vivado hardware server "hw_server" process doesn't close when server is closed

    Vivado hardware server "hw_server" process doesn't close when server is closed. 
    Also, the connecting to the server hangs if a device is physically disconnected and reconnected (usually). 
    The "hw_server" process continually has to be killed via Task Manager, Vivado has to be closed and reopened sometimes as well. 
    Using Vivado 2014.1
    Please fix this. 
     

    I'm on 2014.1 as well (Win7-64).  I have a similar problem with 2 different PCs running the same setup.  The Hardware Manager hangs while attempting some activity (usually reconfig).  I click "Cancel" to dismiss the activity, which causes all of Vivado to hang.  Seeing no other option, I kill Vivado in the Task Manager.  However, this has the unfortunate side effect of leaving an orphaned hw_server process that can't be killed by any means, thus requiring a reboot of the PC.
    This is monumentally annoying.
    Can someone comment on whether this is due to a known issue, and if it's fixed in 2014.2?
     

  • MacBook Pro display doesn't close down properly.

    We have one MacBook Pro that doesn't close down properly. The display just bounces up. Is there any way to fix this or is this something that needs to be fixed by a technician?

    Try blowing out the slots where the two "prongs" come up, and the release button slot (push it in and out a bit while doing this) with compressed air. (use your lungs if you don't have a can of air).
    Often a bit of crumb or other gunk will impede the mechanism enough to prevent the magnets from being able to do their job properly.
    Cheers
    Rod

  • Starts very slowly, doesn't close, runs in background

    Firefox 3.6 opens very slowly, doesn't close but apparently runs in background prompting to either close it or restart . Have tried disabling several addons, to no avail.
    == This happened ==
    Every time Firefox opened
    == within the past couple weeks

    I've narrowed my problem down by chopping pieces of code until it works, and I think I have it narrowed down to the code that uses FlexGraphing but need to check a bit more...
    It's odd that it works in Flex3 builder though, and there are no errors when I run in as AIR. In fact, the app RUNS, since it is in the task manager, but it won't appear.

  • My iphone 5c doesn't close

    Whenever I receive a notification, then the screen of the iphone doesn't close, and if I don't close it, I lose a lot of charge.
    Does this happen also to you?
    How can I fix this problem?
    I had bought the iPhone in christmas 2013

    I was facing the same problem when moving from a Nokia C2 to an iPhone 4S.
    I searched high and low for methods (or software) to transfer my contacts, but found nothing satisfactory and reliable.
    What I did was, on the old Nokia copy all contacts to the Nokia's phone memory.
    (Nokia can use both Sim- and memory contacts)
    Then I took my new Simcard, put it in the Nokia and copied all contacts from memory to the Sim card.
    Next step was to cut the micro Sim from the "normal" size Simcard, put it in the iPhone 4S and used "Import Simcard contacts".
    That option doesn't becomes visible until after the Provider activated the Simcard.
    Done, simple as that, but noone I talked to mentioned this.
    They are probably all "native Apple" users.

  • HT4211 My i pad hang on with information of icloud back up with informtion of "this ipad hasn't been backed up in three weeks. backups happen when this pad is plugged in, locked and connected to wifi"  and doesn't close when press ok button. I am not able

    My i pad hang on with information of icloud back up with informtion of "this ipad hasn't been backed up in three weeks. backups happen when this pad is plugged in, locked and connected to wifi"  and doesn't close when press ok button and still hangon. I am not able to switched off also. How to remove popoup note and entering into ipad applications.

    Hold down the sleep and home keys for about 20 seconds or so and see if it reboots.

  • Gnome-appearances doesn't close, consumes 100% CPU

    I can open and work with gnome-appearances fine, however after closing the gui I find that gnome-appearances is still running and consuming around 100% of one CPU. So I have to kill it manually.
    While running, gnome-appearances is consuming 100% of one CPU, which seems a bit odd but the fact that it doesn't close with the gui is my issue.
    I get no error messages when running from the command line.
    Has anyone else encountered this problem?
    I'm using GNOME appearance 2.20.3
    Thanks

    I'm thinking it is an issue related to the gtk themes. I tried changing the window control theme in xfce earlier today and noticed the same spike in CPU usage (w/o the lingering after closing though).
    Also, while I had gnome installed I was unable to change to a gnome style window control (e.g., mist, industrial, etc.) in xfce. After uninstalling gnome, I can now use those gtk themes in xfce.
    Need to look into this some more.
    edit:
    It seems the spike in CPU usage while changing the window control theme in xfce occurs only when firefox is running. Which makes some sense, although I don't remember that ever being an issue before.
    Last edited by kr22 (2008-01-27 01:57:02)

  • Diagonal lid - doesn't close straight. anyone else?

    my macbook screen doesn't close straight. when it is shut, it hangs over a bit on the left and so isn't flush on the right side.
    it is 3 months old. it has never left my house, never been dropped. i treat it with tlc at all times. i have an ibook of 3 years and that seems so much more solid.
    is it the hinges? any ideas?
    Macbook, (and iBook G4)   Mac OS X (10.4.8)   2GHz 80gb 1GB RAM

    I believe there's a bit of adjustment to these screens/lids. I'd certainly take it in if you have an Apple Store nearby. If that's not feasible I'd at least give Apple a call and explain the situation.
    There maybe a "how-to" somewhere on the net as well but you might as well have Apple do it if it's still under warranty.

Maybe you are looking for

  • Changing the order of playli

    I am using Creative Mediasource Organizer and a Zen Micro. I can drag songs into a playlist and everything will work fine, apart from Mediasource won't let me move songs around into a different order. All the instructions that I can find on the subje

  • Volume too low on ringer and with hands-free headsets

    Both the ringer's volume and the volume within headsets are too low in my new Droid X. When holding it to my ear while talking it is loud enough well below max volume, but hearing people through headsets while driving is often too low with all volume

  • TS3274 Microphone is not working

    MY microphone is not working, how can I specify what is the problem

  • WRT160N Help !

    Hey forum, I have a couple of questions regarding how to secure my wireless connection from others around me. This  is what my network is looking like, but I think my wireless connection isn't correct with that image. I have my wireless router connec

  • What steps should I follow ?

    Hi all, First of all, I am from Holland, I'll try my best not to write in riddles.... I have two 30 minutes DV tapes I would like to edit and than show to my friends in Holland AND the States. How do I start ?? My idea is to import the footage of eac