Need to wait for answer

In the following code, my get.start(); lines, opens another jframe that is used to accept values from the user. There are 2 textfields on the jframe that the user is entering information into. However, once the get.start(); is called, the function proceeds on with itself, and doesn't wait for an answer from the jframe, which is something I understand and know, but my issue is, getting it to wait for the user to input information. I'm not sure what I can do to wait for the information before my code goes through and runs the if(goahead){.... code. 
  public void uploadFile(){
        //   patronObject patron = new patronObject();
        boolean goahead = true;
        getInfo get = new getInfo();
        int result = filechooser.showOpenDialog(this);
        if (result == filechooser.APPROVE_OPTION){
            String filename = filechooser.getSelectedFile().getAbsolutePath();
            System.out.println("filename = " + filename);
            if (filename.toLowerCase().endsWith(".pdf") || filename.toLowerCase().endsWith(".PDF")){
                try {
                    System.out.println("filename in uploadFILE = " + filename);
                    FileInputStream input = new FileInputStream(new File(filename));
                    ByteArrayOutputStream output = new ByteArrayOutputStream();
                    byte[] buf = new byte[1024];
                    byte[] data = null;
                    long num = 0;
                    int numBytesRead = 0;
                    while ((numBytesRead = input.read(buf)) != -1) {
                        output.write(buf, 0, numBytesRead);
                    get.start();
                    if(goahead){
                        //   patronObject patron = new patronObject();
                        System.out.println("go to the printing section");
                        patron.setAction("updatePDF");
                        patron.setPatronID(get.getPatronID());
                        patron.setPDFName(get.getPdfName());
                        patron.setPDF(output.toByteArray());
                        sendPatron();
                }catch(FileNotFoundException ex) {
                    ex.printStackTrace();
                } catch (IOException ex) {
                    ex.printStackTrace();
            }else{
                JOptionPane.showMessageDialog(null, "Please make sure to select only a PDF file");
    }

Use a modal JDialog or JOptionPane.showInputdialog(...) instead of JFrame.
In future, Swing questions should be posted in the [Swing forum|http://forum.java.sun.com/forum.jspa?forumID=57]
db

Similar Messages

  • HT201209 How to get an itunes gift card code, no need to wait for shipping

    Good day to all,
    I want to get an itunes gift card just to download whatsapp on my iphone 3gs. I have my credit card but the billing address is in Haiti, unfortunately Haiti is not in your list of  countries. How can I get itunes gift card code immediately in order to download that application? No need to wait for shipping, just want to have the code to add it to my apple account.
    If you have a better solution, it's welcome.
    Thank you in advance for your reply

    Sorry, but you can't, if you live in Haiti. As you say yourself, there is no iTunes Store for Haiti and you are not allowed to use the iTunes Store of any other country.
    If you live in a country where there is an iTunes Store, check to see if Apple sells physical gift cards in your country and if so purchase and redeem one of those. There is no way to purchase an electronic gift certificate from Apple without a credit card from the country whose iTunes Store you wish to use.
    Regards.

  • If I click 'clear now' in 'offline storage', do I need to wait for an acknowledgement that it has cleared or does it clear instantly?

    Lately, Firefox will not let me reply, forward, or open 'action' when in AOL mail. AOL works fine on Safari. Do I need to clear cache? If so, do I need to wait for an acknowledgment that the cache has cleared before moving from that screen?

    You do not get any acknowledgment if you click Clear Now to clear the cache. It will be done and shouldn't take much time. You can check the about:cache page via the location bar to see if it has worked if you want to be sure.

  • How LONG I'll need to wait for Apple GENIUS fix the incompatibility

    I need to work....How LONG I'll need to wait for Apple GENIUS fix the incompatibility # KEYNOTE and LION???
    What is the best thing I've to do???
    Downgrade the OS??? Change the Plataform????

    Each region has little differences that need to be changed and setup in order for it to work on your phone correctly. Just need to sit and wait...
    Nokia 5800 XpressMusic Red V52.0.007
    Hit the Kudos if I helped!

  • I can't sync my files-when I click sync and need to wait for a while but then nothing happened, not even error notification

    I can't sync my files-when I click sync and need to wait for a while but then nothing happened, not even error notification

    File Sync Links that may help
    -http://helpx.adobe.com/creative-cloud/kb/arent-my-files-syncing.html
    -http://helpx.adobe.com/creative-cloud/kb/cannot-share-certain-types-files.html
    -Size Limits https://forums.adobe.com/thread/1488242

  • I have an ipad 4 running ios 7 but i noticed ios 7 on my ipad seems laggy. I already did a factory reset but it seems doesn't change a bit. Are there any solution for this or I need to wait for the next ios 7 update?

    Am I the only one who facing this problem or there someone else. I did a factory reset yesterday but it still laggy. Do I need to wait for the next ios 7 update or what?

    Hi Amish,
    I should have mentioned that I have signed out of the iCloud Control Panel several times and no syncing occurs.
    Thanks for your response anyway. I appreciate your feedback.

  • What's new in these days?Seeking to persuade, Adobe still insist FP Development. Waiting for answer

    Seeking to persuade, Adobe still insist FP Development. Waiting for answer on line.
    I am an AS3 developer, deeply in love with it. Recently I was very disappointed with Adobe.
    Fp11.8 seems update frequenctly, but nearly no change. New feathers is all the same every time, why? Unity 3d and Fusion Chart has said goodbay to Flash Player, Weather Adobe is also? 

    Not sure exactky what's your point, but FP has been gaining some pretty nice features. The GameInput API, for example, is awesome despite a couple of remaining bugs, and a few cool GPU-acceleration features and updates have been creeping in FP too. I'd assume the frequent updates are more due to stability, while point releases are the ones where you see new features. You may want to double-check the changelog to see what has been changed on every version.
    Unity has said goodbye to Flash because it solved a problem that was virtually nonexistant, and Fusion Charts would do better with a more cross-platform solution (e.g. Canvas/SVG) considering their target audience. I don't think either have anything to do with Flash technology per se.

  • HT201407 i Perform this , but stil problem occur, could not activate, what can i do. it say server is temporary unavialable. Actually i update my iphone 3gs from 4.1 to 6.1.3 ...   What can i do, reply iam waiting for answer.

    i Perform this , but stil problem occur, could not activate, what can i do. it say server is temporary unavialable. Actually i update my iphone 3gs from 4.1 to 6.1.3 ...   What can i do, reply iam waiting for answer.

    Is your phone jailbroken by any chance?

  • Call unix script within Servlet - need to wait for completetion

    Hi,
    I have a servlet which grabs some information from my web form and then calls a unix script.
    This already works fine and does what i need it to do. I now need to add some functionality where i can get the servlet to wait for the unix script to complete before carrying on and then redirecting back to the user.
    the code i have for the current servlet is:
             * EXECUTE THE UNIX COMMAND.
            Runtime   oRuntime  =     Runtime.getRuntime();
            Process   oProcess   =     null;
            String[]      cmd          =     {"/bin/sh", "-c", sPath}; // UNIX
             * ERROR CODES 3 = File not found
            try
              oProcess = oRuntime.exec(cmd);
            catch(Throwable t)
              t.printStackTrace();
            }I am assuming i need some sort of wait method to handle this. Any help would be greatly appreciated.
    Thanks
    Graham

    ok.. you code is fine.. you can run any shell script or program using the exec() method. if you need to wait till the process finishes then you need to call the method waitFor() in class Process.. the method blocks the parent thread (servlet) till the sub process (your exec'd script or program) terminates.
    hope that solves your problem.. :-)
    Pls tell me one more thing.. are you using netBeans or Eclipse for executing the programs or you use standalone tomcat to deploy the application. I have problem in execing programs when i deploy in tomcat 5.5 and the same application works fine in netBeans 5.0. if you know pls help me too..
    Thanks,
    -- abdel Olakara.

  • Need Help waiting for user input.

    I've got a simple card game, which I've pretty much made all with swing. I have a JTextField and a JButton. I want the user to input a number into the textfield and the click the button which fires the action listener. This then takes the text and reads it and set a boolean hasBid to true. I don't want to program to continue until this has happened so I made an empty while(!hasBid) loop. The first time through, the program starts and stop until the user inputs something and click the button. The second time through, however, the whole window freezes. For somereason object aren't even being displayed which are displayed before this while loop. Without the while loop, everything runs fine, but the program won't stop to wait for input.
    So, my question pretty much is how can I get the program to stop for user input in a function which will be called multiple times. I don't want to use a JOptionPane or anyother pop-up box. If my way won't work, I'd really like to know of another way. Thanks for any help!

    you simply need to separate the functionality of your input object and the card game into two threads. as sanbingo said, running in a while loop prevents your GUI from even drawing its components.
    Remember: AWT/Swing is an event driven interface! so only events can/should cause some action to happen.
    i'd properly implement an event listener which is fired when the input is received. the listener is your game class which upon receipt of the event starts playing. when its done, its done, ie doesn't do anything until it receives an new event from your input object.
    thomas

  • On iphoto, my import was interrupted and now I can't exit or re-import my photos because it says that I need to wait for the previous import to finish. How can I fix that?

    As I was Importing, it kept freezing, so I unplugged my phone and now I can't exit or do anything on iPhoto because I have to wait for my non existent download to finish.

    Apple menu ==> force quit
    LN

  • Why did the text plan topic below get locked??? Was waiting for answer...

    What's up with that...I was waiting for an answer from the ATT rep...why did it get locked?

    iTweaker wrote:
    When I said courtesy, I meant to let people know WHY something was locked down or deleted. I thought they could do this as a courtesy to the people who posted, instead of leaving them wondering what happened and why their thread was stopped.
    Thanks for your suggestion, I'll search for the ATT forum.
    I believe that the person who provides the first reply to the OP's question receives an email from the mods informing them that the thread has been locked. They may sometimes give the reason for this, but often not. Not sure why it seems not to go to the OP?

  • Do I need to wait for update?

    A friend of mine gave me this iPad 2 long time ago and it is a iOS 4. I barely use the iPad. So today I wanted to install games such as pvz2 but it said it need iOS 5 or more. When I went to my MacBook to update it. And I click "check for updates" all it say is "This model is iOS 4" I kept on clicking it but when I read the word below it. It say iTunes will check for updates in 12/12/2013 so I did in the next day but it also say the same thing as previous day and it say iTunes will check for updates in 19/12/2013. And the problem is should I wait?

    this is what it say

  • Why do I need to wait for an engineering for an al...

    I'm moving home at very short notice due to a death in the family. I'm an existing BT customer moving to a rented home which 6 weeks ago had a working phone line. I work from home via IP and webex etc so having a working phone line and broad band are incredibly important.
    I've been given a date of the 7th of November for an engineer visit and have been told that a new phone line must be installed, with advice that they may not even need to access my property. This visit is costing me £130 or an extnesion to my contract.
    I don't understand why a new phone line must be installed, there is already a working phone line, I don't understand how a new phone line can be installed with no access to the property either?
    I am basically going to have to go and pay the local hotel for office space until this line is installed, so I am looking for an explanation of why it's going to cost me hundreds of pounds to have a line that was working very recently reactivated. It seems utter nonsense. If BT can cut someone off at the flick of a switch, why can't they turn it back on.
    I'm also concerned by the fact that they are not turning off my old line until the 7th, meaning that someone else could use the line in that time, they haven't even given me the option of plugging a phone in and giving it a go as they won't commence until the 7th, it all seems quite strange to me. Any explanations from BT would be welcome.
    The last time I moved home it took several months to get a working phone line, many threats of charges and eventually admitting it was their fault. I can't afford more time off work to get this sorted, and I'm very angry at having to sign a new contract after being a customer for years just to get an already working phone line reactivated!

    Welcome to this forum.
    This is a customer to customer forum only, where forum members, who are only BT customers, can help each other with BT Retail products and services.
    Anything you post here does not go to BT. Although the forum is moderated by BT, not all posts are read.
    The lines are provided by Openreach, for all service providers, so the existing line may have been used by a different service provider, and would need re-connecting within the exchange, to BT equipment.
    You could try plugging a phone in, and see if there is dialling tone. You can dial 1470 17070 to get the number, and dialling 150 should tell you who the service provider was.
    When you mention that you need this as you work from home, and its critical that it works, and repaired quickly if it goes wrong, then a BT Business line would would be the best option, as it will give you a much faster repair time, should anything go wrong.
    See http://business.bt.com/phone-services/bt-totalcare/
    The fact that you are having to rent office space, would tend to indicate that it is important to you.
    There are some useful help pages here, for BT Broadband customers only, on my personal website.
    BT Broadband customers - help with broadband, WiFi, networking, e-mail and phones.

  • How long I need to wait for platform change from windows to mac?

    I filled form on web and I waiting one week and no one want to help me?

    The Cloud allows install on both Windows and Mac... what program and version do you have?

Maybe you are looking for

  • Error in start routine

    Hello All, I am trying to activate a couple transformations for cubes in purchasing. I am getting the error in start routine. I checked the start routine. E:In PERFORM or CALL FUNCTION "ROUTINE_9998", the actual parameter "SOURCE_PACKAGE" is incompat

  • Order by clause in PL/SQL cursors

    I am trying to execute a procedure with some input parameters. I open a cursor with a select statement. However, the order by clause in the query does not recognize parameter sent through the procedure input parameters. For example: open <<cursor nam

  • How to create a message inside BPM

    I am using interface mapping inside BPM in order to check source message. This mapping produced new interface (I have declared container with that type) then I have swith block that check countainer with new intrface. In SXI_CAHCHE I get an error VAL

  • Jquery mobile with phonegap

    Hello All, I am planning to create a new mobile app project developed by Jquery and html5 css3, and integrate it with the Phonegap. also planning to get my dynamic data from wordpress site by JSON. my question here is it possible that JSON data list

  • Converting PDF DOWN to version 1.2

    Hello- I have a user in my office who needs to send PDFs to the far East, in a government where apparently all PFDs have to be version 1.2. One user is able to do this in Acrobat 7 by printing to a PDF, which for some reason takes the PDF from versio