How do i make program wait for user input in some dialog box?

basicly function public UserData getUserData()
displays window and returns a value when somebody has pressed OK in JFrame. How?

Extend from JDialog instead of JFrame and it'll give you the waiting that you need.
To use a JFrame is a little more involved.
I had to the other day also. I wanted to have a dialog that would be both a dialog and a JFrame. Reason: when the app started up, I wanted to get some data from it (and have it appear in the task bar for normal application selection), and also wanted the app to call the same window when running but as a dialog (ie: no extra task bar icon). However only the JDialog stopped the calling thread for the dialog.
To get the JFrame to do the same, I invoked a thread and piled all of the logic into that, and when the user did all that I wanted them to, closed the Frame and released the thread with all of the statefull stuff that I wanted.
Worked a treat.

Similar Messages

  • How to make Flash to wait for user input

    Hi,
    I found this PHP script, then I made some changes to make it
    FEED the Flash user interface with online user input.
    The main concept of this script is WAITING for user input, so
    it shows the messages and then go to next line and so on.
    The user input go to directly to TEXT file which writes in
    lines, each line has a unique id = (mag_id).
    There "get_msge.php" which works as the middleware between
    FLASH and messages text file.
    The problem, its doesn’t show any data while there are
    data in the text file.
    Help here please, best regards.
    This is the link of
    problem illustartion
    AS is:
    // create an object to store the variables
    varReceiver = new LoadVars();
    // load the variables from the text file
    varReceiver.load("get_msg.php?file_id=1&msg_id=1",
    "POST");
    // trigger something - when the variables finish loading
    varReceiver.onLoad = function(){
    //the variables have finished loading
    if (this.msg_id == 1) {
    _root.xmsg1_swf.text = this.msg;
    _root.xmsg1_ch.text = this.msg;
    gotoAndPlay("line2");
    } else {WAIT }
    PHP is:
    <?php
    //get these values from the FLASH
    $file_id_swf = $_POST ['file_id'];
    $file_name = "messages/messages".$file_id_swf.".txt";
    $msg_id_swf = $_POST ['msg_id'];
    // [0] ."||".[1] ."||".[2] ."||". [3] ."||".[4]."||". [5].
    //$msg_id."||".date."||".time."||".$from."||".$to."||".$msg.
    $fp = fopen ($file_name, 'rb');
    while (!feof ($fp))
    $msg_txt = fgets ($fp, 1024);
    $line = explode ("||", $msg_txt);
    $msg_id = $line[0];
    $from = $line[3];
    $to = $line[4];
    $msg = utf8_encode ($line[5]);
    if ($msg_id == $msg_id_swf)
    echo
    "msg_id=".$msg_id."&from=".$from."&to=".$to."&msg=".$msg;
    }//while
    fclose ($fp);
    ?>

    Well, given the things that you've written, I don't think it
    could. There technically isn't any code in flash that lets it
    "wait." In order to "wait," you must run the script over again
    until some condition is met.
    However, your code does look accurate. Why do you need to
    wait? The onLoad function will be invoked WHEN something is loaded.
    So, I don't see the reason for the "waiting."
    In addition to that, I would like to say that using text
    files isn't that great with flash. I have done this before and
    noticed several problems with using text files. The biggest problem
    is that the text files are cached after being loaded. Every time
    you re-load it again, you will get what you got the first time
    until you reset your cache (ie. close your browser). I suggest
    using MySQL. (Just my thought.)

  • How do you keep a VI running while waiting for user input?

    I have a VI that:
    1.  The user enters set points.
    2.  The user starts the VI and the VI sends the set points to an external process via a serial interface.
    3.  The VI  stops running.
    4   The user waits for the external process to complete.
    5.  Repeat sequence. Go to Step 1.
    This works well except for one small problem.  Starting the VI in step 2 causes an external micro controller to reset.  During the reset it will ignore set point commands.  To get around this problem a delay has been added between when the VI opens the serial port and when the VI sends the set points to the external process   Is it possible to keep a VI running continuously in this type of application, thereby eliminating the start up and shut down of the serial interface?
    If yes, how do you keep a VI running while waiting for user input?
    Howard

    The ones for the event structure specifically. I'm posting from my phone. Look at the basic ones for user input. even a simple while loop with a boolean and a case statement would work.

  • 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

  • How can I make (automatic) accounts for users of my adobe muse site?

    Adobe, google, facebook and more site haves accounts for his users, but how can I make a system with accounts for users of my adobe muse site?

    Hi,
    Try some suggestion given in this thread
    http://forums.adobe.com/message/5362643#5362643

  • Best way to make program wait for input from NI USB 9162?

    Hi, I'm somewhat new to Labview, but through all the tutorials and online help I'm still having trouble getting this to function properly.
    The USB adapter is hooked up to a network cable split into single wires reading in a voltage coming through several seperate oscillators.  
    Testing in the lab, the program included below works fine when I run the program, then quickly administer a shock to the table.  In the real world scenario though, I'm trying to make the program wait to record data until the first shock reaches the first oscillator before recording data, but I just can't seem to find an easy way to make this work.
    Attatched is an example of the program.  Any help would be greatly appreciated.  Thank you. 
    Attachments:
    Acq&Graph Voltage-Int Clk-rh-tt-1.vi ‏56 KB

      Hi,
    I think I have the answer you're looking for! Please see the attached VI.
    I moved the graph indicator inside the "true" case of the case structure. Before, your VI was sending data  to the graph from an empty timestamp constant with each iteration of the "false" case. Now the VI only sends data to the graph if a true is read.
    If you're wondering why it takes a bit of time for your graph to stop updating before it stops writing new data, it's because you're filling up a buffer of sampled data by using a queue. If you're writing to the buffer faster than you're reading from the buffer, you may encounter an "overflow" situation when the queue gets full. To avoid this, you might consider using a notifier rather than a queue. It's the exact same thing as a queue, but it gives you only the most recent value, allowing new values to overwrite old values.
    Hope this helps.
    Regards,
    Dan Richards
    Certified LabVIEW Developer
    Attachments:
    producer consumer DAQmx threshold.vi ‏57 KB

  • Wait for user input in for loop

    I'm pretty new to labview and I'm having a hard time figuring out how to do this. Basically, I need the user to press a GO button and data aquisition will take place saving it in an array, then the program will wait for the user to press the GO button again and the data aqusition will add more values to the array, and the whole process will repeat 5 times and finally it will average the values.
    To try and figure out how to do this, I tried making a program that loops 5 times and adds a random number to an array with each loop (using shift registers) but I CANNOT figure out how to make each loop iteration wait on the user to press a button. Any advice?

    Hi Roger,
    you can use a dialog in your for loop, or better you use an event structure to react on user inputs. If you use the event structure you can count the button press events and store them in a shift register. With a compare function you can check if your limit is reached and react on it.
    Mike

  • Wait for user input in middle of method

    I have a method in the middle of which I want to give the user a chance to click one of several Buttons. Here is the basic design of the method:
    Private Sub MyMethod()
    'Code before I need extra input
    'This is where I want to wait for the user to click a Button
    'This is where I will be using the results from the clicked Button
    'The waiting for input and using the results will happen multiple times inside a loop
    End Sub
    The code is in a loop, so exiting the method and putting the rest of the code in the Button handler would not be appropriate. How can I ask the user for input and then return that input to the method where I left? I seem to be tempted to use some kind of async
    method, but since the input will be coming from the user (not another method), that doesn't seem like it would be right (but I don't have a huge amount of experience with async, so I could be wrong about that). Can anybody help me? Thanks.
    Nathan Sokalski [email protected] http://www.nathansokalski.com/

    Hi Nathan,
    You're on the right track: you'll need to await an Async function to put a delay in the middle of your method. The button click will notify the async function to finish.
    You could write a custom function which returns a Task and waits for the notification from the button:
    Task WaitForButtonClickAsync()
    // wait for button click
    and then await that in your main function:
    async void BigNastyFunction()
    await WaitForButtonClickAsync();
    The next question is how to let the button click notify WaitForButtonClickAsync to return.
    We could spin up a worker thread and have it block waiting on a notification, but there is no need to complicate things like that: WaitForButtonClickAsync can just return
    Task.Delay(timeout, cancellation token) and then when the button click handler fires it can cancel the delay.
    See
    Asynchronous Programming with Async and Await and
    Async Cancellation: Bridging between the .NET Framework and the Windows Runtime for more information on cancelling a task.

  • WORKFLOW PROCESS IS NOT WAITING FOR USER INPUT LIKE RE-ASSIGN FUNCTION

    I am using Stand alone Workflow 2.6, In my workflow process
    which is an Issue tracking system which is working fine. On Enhancement I would like to create my own RE-ASSIGN function which will, Change the ownership of an issue totally to other user.
    For this I Created a package(CHANGE_OWNER.CREATE)which will show list of Users and Comment field(Just like Re-Assign).
    Here user can pick other user, and add comment,
    once submit for that Item key I am updating the workflow notification table so that paritcular issue ownership will be changed.
    In my workflow process I created a lookup code called "Change Owner". On click of Change Owner it will call the Function
    in workflow process which will call CHANGE_OWNER.CREATE, here
    the workflow process supposed to wait and get the User to be
    changed. BUT THE PROCESS IS NOT WAITING, IT JUST DISPLAYED THE
    SCREEN AND CONTINUED THE WORKFLOW PROCESS. I WANT THE MY
    WORKFLOW PROCESS TO BE ACT AS RE-ASSINGN BUTTON WHICH WILL WAIT
    FOR THE USER INPUT.
    HOW TO DO IT.
    Thanks
    Bala.

    Hi Bala
    What enhancements were you adding to the Workflow Reassign/Delegate feature, which included being able to add comments? A good idea is to look for any differences between how workflow implements the reassign feature, and your customization.
    Also, make sure you only use the Public documented PL/SQL APIs and do not update the tables directly to ensure no Support or Upgrade Issues.
    Cheers
    Mark
    I am using Stand alone Workflow 2.6, In my workflow process
    which is an Issue tracking system which is working fine. On Enhancement I would like to create my own RE-ASSIGN function which will, Change the ownership of an issue totally to other user.
    For this I Created a package(CHANGE_OWNER.CREATE)which will show list of Users and Comment field(Just like Re-Assign).
    Here user can pick other user, and add comment,
    once submit for that Item key I am updating the workflow notification table so that paritcular issue ownership will be changed.
    In my workflow process I created a lookup code called "Change Owner". On click of Change Owner it will call the Function
    in workflow process which will call CHANGE_OWNER.CREATE, here
    the workflow process supposed to wait and get the User to be
    changed. BUT THE PROCESS IS NOT WAITING, IT JUST DISPLAYED THE
    SCREEN AND CONTINUED THE WORKFLOW PROCESS. I WANT THE MY
    WORKFLOW PROCESS TO BE ACT AS RE-ASSINGN BUTTON WHICH WILL WAIT
    FOR THE USER INPUT.
    HOW TO DO IT.
    Thanks
    Bala.

  • Program does not wait for user input

    Hi everyone,
    i am working on a program and there are 2 problems that i can't figure out. Since they are 2 different topics, I will do 2 posts.
    Just to give you some background on the program, it is a program that reads 3 txt files into 4 different arrays. The files contain student names, student ID numbers, number of credits and gpas. the user enters the names of the 3 txt files and then is given a list of options to choose from. I am having problems with option 7.
    The code lists the student information, but it does not stop to request the name of the student from the user. Instead, it prints the system out line requesting the name and then prints all the information for every student in the file. I can't figure out why this is happening. Here is the code for the option:
                    else if (choice == 7)
                            System.out.print("Please enter the student's name: ");
                            student_name= sc.nextLine();
                            for (q= 0; q <= num_students-1; q++)
                                    if (student_name.equalsIgnoreCase(studentname[q]))
                                            System.out.println();
                                            System.out.println("Student's name: " + studentname[q]);
                                            System.out.println(studentname[q] + "'s ID#: " + studentid[q]);
                                            System.out.println(studentname[q] + "'s number of credits: " + credits[q]);
                                            System.out.println(String.format(studentname[q] + "'s gpa: " + "%.2f",gpa[q]));
                                            if (gpa[q] < 2.00)  
                                                    System.out.println(studentname[q] + "'s status: can't graduate");
                                            else if (gpa[q] >= 3.45 && gpa[q] < 3.65)
                                            else if (gpa[q] >= 3.45 && gpa[q] < 3.65)
                                                    System.out.println(studentname[q] + "'s status: cum laude");
                                            else if (gpa[q] >= 3.65 && gpa[q] < 3.85)
                                                    System.out.println(studentname[q] + "'s status: magna");
                                            else if (gpa[q] >= 3.85)
                                                    System.out.println(studentname[q] + "'s status: summa");
                                            else if (gpa[q] >= 2.00 && gpa[q] < 3.45)
                                                    System.out.println(studentname[q] + "'s status: ");
                    System.out.println();
                    System.out.println("1.  List student names");
                    System.out.println("2.  List credits");
                    System.out.println("3.  Show total credits");
                    System.out.println("4.  List gpas");
                    System.out.println("5.  List gpas in ascending order");
                    System.out.println("6.  Show weighted average of gpas");
                    System.out.println("7.  Show information about a given student");
                    System.out.println("8.  Add a new student");
                    System.out.println("9.  Quit");
                    System.out.println();
                    System.out.println();
                    System.out.print("Enter your choice: ");
                    choice= sc.nextInt();
                    System.out.println();
                    // Option 9 quits program
    }          Any help you can give me would be greatly appreciated.

    Ok, I tinkered with the code a bit. Now it will show the info for only one student, however, it is not giving any results. Here is the output I am getting:
    Enter your choice: 7
    Please enter the student's name: mary
    Student's name: null
    null's ID#: null
    null's number of credits: 0
    null's gpa: 0.00
    null's status: can't graduate
    1. List student names
    2. List credits
    3. Show total credits
    4. List gpas
    5. List gpas in ascending order
    6. Show weighted average of gpas
    7. Show information about a given student
    8. Add a new student
    9. Quit
    Here is the updated code:
                    else if (choice == 7)
                            System.out.print("Please enter the student's name: ");
                            student_name= sc.next();
                            for (q= 0; q < num_students; q++)
                                    if (student_name.equalsIgnoreCase(studentname[q]))
                                            System.out.println();
                                            System.out.println("Student's name: " + studentname[q]);
                                            System.out.println(studentname[q] + "'s ID#: " + studentid[q]);
                                            System.out.println(studentname[q] + "'s number of credits: " + credits[q]);
                                            System.out.println(String.format(studentname[q] + "'s gpa: " + "%.2f",gpa[q]));
                                            if (gpa[q] < 2.00)
                                                    System.out.println(studentname[q] + "'s status: can't graduate");
                                            else if (gpa[q] >= 3.45 && gpa[q] < 3.65)
                                                    System.out.println(studentname[q] + "'s status: cum laude");
                                           else if (gpa[q] >= 3.65 && gpa[q] < 3.85)
                                                    System.out.println(studentname[q] + "'s status: magna");
                                            else if (gpa[q] >= 3.85)
                                                    System.out.println(studentname[q] + "'s status: summa");
                                            else if (gpa[q] >= 2.00 && gpa[q] < 3.45)
                                                    System.out.println(studentname[q] + "'s status: ");
                                    else
                                            System.out.println("Student name not on file.");
                    System.out.println();
                    System.out.println("1.  List student names");
                    System.out.println("2.  List credits");
                    System.out.println("3.  Show total credits");
                    System.out.println("4.  List gpas");
                    System.out.println("5.  List gpas in ascending order");
                    System.out.println("6.  Show weighted average of gpas");
                    System.out.println("7.  Show information about a given student");
                    System.out.println("8.  Add a new student");
                    System.out.println("9.  Quit");
                    System.out.println();
                    System.out.println();
                    System.out.print("Enter your choice: ");
                    choice= sc.nextInt();
                    System.out.println();  
                    // Option 9 quits program
    }

  • How to satisfy "Waiting for user logon" requirement for multiple machines

    Let me preface this by saying I know the "real" solution is to make my package run whether or not a user is logged on, but here me out.
    I have some packages that someone else builds where they're set to only run when a user is logged on, which then in Monitoring builds up quite a few "waiting for user logons" since some machines go unused for a week at a time.
    Is there any slick way to get around that?  or to have a script which logs on to a list of machines then logs off after say 10 minutes so the SCCM installs can occur?

    if you are worried about packages deploying to user machines irrespective of logged in or not,why dont go with program settings 'whether or not used logged in' instead of choosing 'only when user logged in' and try for other alternatives to install app
    .'whether or not used logged in' will straight away install the applications for you .
    Eswar Koneti | Configmgr blog:
    www.eskonr.com | Linkedin: Eswar Koneti
    | Twitter: Eskonr

  • How to make field key for user fields cant be changed after project release

    Dear Expert,
    How can we make field key for user fields cannot be changed once we release the project/wbs?
    Cheers,
    Nies

    Do you mean 'field key' in the project profile in SPRo?
    I think after a project is created a change in the field key wont affect the fields in CJ20N..
    Can you verify?
    Regards
    Ramesh

  • How can I terminate TestStand without requiring user input?

    I want to completely terminate TestStand and any running sequences. Engine.ShutDown seems to have a delay waiting for user input. Is there a function call that disregards this delay and immediately either kills all sequences or unloads them and kills TestStand?
    I am trying to do this in C++.

    To BMas05 -
    Yes if you set,
    Setting: "Exiting"
    Condition: "When Executing"
    Time Limit: "2"
    Action: "Terminate Execution"
    On shutdown, if an execution is running for more than 2 seconds after shutdown is initiated, TestStand will attempt to terminate the execution.
    Now if you wanted to escalate terminations that take too long you could additionally set,
    Setting: "Exiting"
    Condition: "When Terminating"
    Time Limit: "4"
    Action: "Abort Execution"
    So now on shutdown, if an execution is terminating for more than 4 seconds after termination is initiated on shutdown, TestStand will attempt to abort the execution.
    Now if you wanted to escalate aborting executions
    that take too long you could additionally set,
    Setting: "Exiting"
    Condition: "When Aborting"
    Time Limit: "6"
    Action: "Kill the Execution's Thread's"
    So now on shutdown, if an execution is aborting(typically unresponsive) for more than 6 seconds after abort is initiated, TestStand will attempt to kill the unresponsive thread.
    Scott Richardson (NI)
    Scott Richardson
    National Instruments

  • How to pause while document printing and wait for user actions.

    How to pause while document printing and wait for user actions. (for sample: pressed button). Pause after each printed pages.

    Print page by page after considering the user actions!

  • How do you make Mozilla listen to users and stop FFFFirefox Auto Updating despite being set to NOT auto update?

    I am spitting nails
    After all the STUPID problems outlined here
    https://support.mozilla.org/en-US/questions/999831?esab=a&s=&r=0&as=s
    I set Firefox to stop auto updating,
    Then the other day I installed a new user on my laptop, when they loaded Firefox it auto updated MY version of Firefox.
    Has NOTHING been learnt?
    STUPID STUPID STUPID STUPID STUPID
    So I have 2 questions
    How do you make Mozilla listen to users?
    and how do prevent what happened to me happening again?

    SuperSluether
    Not a millionth, you have only provided 150 answers and I doubt they were all this issue.
    If you don't like it, don't use it.
    If a business took this attitude they would soon be out of business
    Updates help KEEP YOU SAFE
    Sometimes, but in my experience FFirefox updates can really screw up your system, lose you data, mess up your user interface. I have run IT for one of the biggest intranets on the planet and we never allowed even Mictosoft updates until we did User Acceptance Testing and understood the impact of the upgrade. I am a grown up not a child, I have system where I test updates for performance, security and impact, I WILL DECIDE when I want to install it. If Mozilla wants to provide real security updates I would take them but if you look at the link in my OP you will see it said an update was security and it completely messed up.
    Updates add tons of great new features
    Actually with FFirefox in my experience they take more away than they add, things I did not ask them to take, they do not look at my config and leave my settings as they were and then tell me about new options, no they completely screw my productivity as it takes days to figure out how to undo the kwap they have added. Copying the AWFUL Chrome interface is not an improvement, Google has one of the worst UI's on the planet accross all their products.
    Firefox is designed to be customized PER USER, NOT CROSS-SYSTEM
    There are some things that benefit from being per user and some that are per machine, windows has group policies per machine and per user. My OP is telling Mozilla that this is another area where they have "designed" badly, I tell them this so that they improve it and in the vain hope that there is some config setting that will stop this nonsense.
    So SuperSluether you have not really helped, all you seem to say is FO if you do not like it. Good job you do not run a business. With that attitude probably best you do not contribute.

Maybe you are looking for

  • How long does it take to get your iPhone 5 battery replaced?

    For anyone who had their iPhone 5 battery replaced in the replacement program, I was wondering if you could tell me how long this took and what the procedure is. Can you do this at a Genius Bar? I'm probably going to have no more than a few hours to

  • Display blob with forms6i

    Hi, i thought it would be easy ti find how to do it nut from searching this site and with google i couldn;t find the answer for that. i have blobs in a table (jpg,doc,pdf ...) . how can i display those blobs (jpg,doc,pdf ...) in forms6i ? can you giv

  • JSP Deployment

    How do i Deploy JSP files?. do i have to use only Tomcat or Can I use Java Web Server?.

  • Is there a keyboard shortcut to mirror a macbook air on a VGA projector?

    I know I can mirror displays by going through the system preferences then displays. But I would like to be able to swith from mirroring to not mirroring quickly, without going through the system preferences every time.  Is there a keyboard shortcut?

  • Error code 6: Generic I/O error with cRIO TDMS

    Hi, I am trying to use the TDMS VIs in LabVIEW 8.6, but the open TDMS VI is giving me error code 6, the "Generic I/O error".  The file path is specified like this: "c:\data\lotsofdata.tdms".  Anyone out there have an idea of what I could do to get th