Multiple Popups when I want one at a time

Hi, I'm writing a gui, and I am having difficulties managing popups. Some of my tasks require a password, so I made a task performer class that prompts for a password and performs the given task with that password. Now the problem is, right after I call the performTask method (which initializes the PasswordPrompt) I create a yes or no JOptionPane dialog. Both the PasswordPrompt and the JOptionPane dialog appear at the same time when I want the JOptionPane to only appear after the PasswordPrompt has been disposed. The task performer adds itself as a listener to the password prompt, which notifies the performer once the password has been submitted.
I'm not going to write out all of my code, but here is the general idea.
public class TaskPerformer {
    public void performTask() {
        // Opens a password prompt that I wrote.
        // The TaskPerformer is passed to the password prompt
    /* When the okay button is pressed in the password prompt
    *  this method is called with the password entered by the user
    public void give password(String password) {
        //The task is actually performed here.
public class MyMain {
    public static void main(String [] args) {
        TaskPerformer tp = new TaskPerformer();
        tp.performTask();
        if(JOptionPane.showConfirmDialog(null, "Would you like mashed Potatoes with your turkey?") {
            System.out.println("yay mashed Potatoes!");
}I'm sure I need to use something like wait() and notify(), but I'm really not familiar with these.

I think you can solve your problem if you choose to use a modal dialog as the container
for your password-entry-panel.
See example below:
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
public class Test
     public static void main(String[] args)
          final JDialog dlg = new JDialog();
          /* if you set modality to 'false', the JOptionPane will come immediately,
           * when 'true', The JOptionPane will come AFTER you click ok */
          dlg.setModal(true); 
          dlg.getContentPane().add(new JPasswordField(40), BorderLayout.NORTH);
          JButton okButton = new JButton("ok");
          okButton.addActionListener(new ActionListener()
               public void actionPerformed(ActionEvent e)
                    dlg.dispose();
          dlg.getContentPane().add(okButton);
          dlg.pack();
          dlg.setLocationRelativeTo(null);
          dlg.setVisible(true);
          JOptionPane.showMessageDialog(null, "hi there!");
}Hope this helps!

Similar Messages

  • Multiple file uploads, or only one at a time?

    I have multiple files in folders on my iPad.  I want to upload entire folders of documents.  So far I have only been able to upload one document at a time.  Then after uploading, I have to put them in acrobat.com folders one document at a time.  It is very time consuming.  Is there any way to upload multiple files at one time?  Once the documents are uploaded, is it possible to move multiple documents into a folder at one time?  Or does each document have to be a separate upload action, and each move into folder a separate document-by-document one at a time?

    On my iPad I have been opening and saving pdf's in Adobe Reader.  I would like to upload these pdf files from the iPad Adobe Reader to acrobat.com.  I have thus far been uploading them from the iPad one fie at a time.  It is very slow and tedious.  There is also no way to get multiple pdf files from the iPad Adobe Reader to a computer except one file at a time.  So it seems that once I used the iPad Adobe Reader app to save the files, I am stuck with one file at a time movement.  I did, however, find that once I get files to acrobat.com, I can move multiples files at a time into folders on acrobat.com via the iPad.  The problem is getting them uploaded from the iPad Adobe Reader app to acrobat.com. Is there a solution I'm missing, or am I correct in my understanding of the iPad Adobe Reader app upload situation?

  • I recently upgraded my Macbook pro with a new Hard Drive.  I then transferred the data using Time Machine.  Now when I want to backup using Time Machine again, it won't do it as it did before to the same external HD.  How can I get it to reconnect?

    Purchased a new, larger solid state drive to replace my old drive.  I installed OSX then I had Time Machine do it's magic. 
    Now when I want to do a backup using Time Machine, it tells me that the external HD is full.  When I did so prior to upgrade, it would erase old backups and then do a new backup.
    Please help.  I am worried about losing files, and am tired of seeing the "Time Machine hasn't backed up in xxx days" Error Message.
    Thanks.

    it thinks yours is a new machine so it doesn't want to start deleting another machine's backups
    see the bottom of this page
    http://pondini.org/TM/19.html

  • How do I use itunes with multiple iphones when syncing each one

    When using one computer how do I make sure each iphone doesnt get all the contacts when I have multiple i phones?

    How to use multiple iPods, iPads, or iPhones with one computer

  • I'm getting multiple popups when i click on bookmarks

    when i click on bookmarks i get a bunch of popups...not all the time but
    sometimes...they show up on my status bar and this morning they actually crashed
    my computer...

    Sometimes a problem with Firefox may be a result of malware installed on your computer, that you may not be aware of.
    You can try these free programs to scan for malware, which work with your existing antivirus software:
    * [http://www.microsoft.com/security/scanner/default.aspx Microsoft Safety Scanner]
    * [http://www.malwarebytes.org/products/malwarebytes_free/ MalwareBytes' Anti-Malware]
    * [http://support.kaspersky.com/faq/?qid=208283363 TDSSKiller - AntiRootkit Utility]
    [http://windows.microsoft.com/MSE Microsoft Security Essentials] is a good permanent antivirus for Windows 7/Vista/XP if you don't already have one.
    Further information can be found in the [[Troubleshoot Firefox issues caused by malware]] article.
    Did this fix your problems? Please report back to us!

  • AirPrint creates multiple copies when printing just one...

    It's driving me mad. I have a HP1217nfw, AirPrint works, but when I try to print one copy, it prints out multiple copies, leaving me scrabbling for the Cancel button and doing everything to cancel the multiple prints it churns out regardless. This leads to me hitting the printers Off button as the only way of stopping things, which then causes a paper jam.
    Any ideas? I have updated to the latest firmware for the printer, but it's made no difference either from my new iPad Mini Retina or the iPad 2.
    David

    Many thanks to you 'both'   Yes, I had the old version of the firmware which was updated and now has fixed the issue.
    I rang HP tech support about a problem with 10.8 OSX drivers and they told me the printer is no longer supported. Its just over a year old.....
    I could not get any of the drivers to install, then found on another forum that the issue was fixed by installing 10.7 drivers. All is now well, but thanks for this, I was going round in circles.
    David

  • Multiple Online Numbers - Only want one forwarded

    Hey there, am hoping someone can help with my query re multiple online numbers.
    I have one Skype account, and multiple online numbers. One number is for a 'home' number, the other is for a 'business' number. I was hoping to set up call forwarding such that only the 'business' number is directed to my mobile phone. The 'home' number will ring on the computer or go through to voicemail.
    Is this possible to setup? I am thinking I may have just spent money for nothing, as I may possibly have to setup a brand new account for my business skype and setup a new online number here as it appears you can only forward all Skype calls, not selectively.
    Here's hoping I'm wrong and you can all help me out
    Thanks.

    Call Forwarding applies to the Skype Name that is associated with an Online number, not the Online number directly
    so if you call forward a Skype Name that has multiple Online numbers associated with it, then calls to any Online number are going to be forwarded, as are incoming Skype calls as well
    Regards,
    Neil

  • How to avoid deadlock when multithreading updates one table same time?

    Multithreading calls the stored procedure at the same time to update data in one table. For a instance,
    Table1
    Col1 Col2 Col3
    C1 1 1
    C1 2 2
    C1 3 3
    C2 1 1
    Table2
    Col1 Col2 Col3
    C1 1 10
    C1 2 4
    C1 3 3
    C2 1 1
    There are several steps I want:
    1. Get the data in Table1 where Col1 = C1 in a cursor which has Col1 column and Col2 column.
    2. Cycle them one by one, and get the Col3 data from Table2 where Col1 = C1 and Table2.Col2 = Table1.Col2. (Due to deadlock is my concern, we use temp table, definityly it is not a good way. :( )
    3. Update Table1 Set Col3 = Table2.Col3.
    My new idea is when I get the collection from Table1 which Col1 = C1, I use this way below.
    First I set transaction in below way.
    SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
    Then
    select * from Table1 where Col1 = C1 for update nowait;
    In my opinion, if one thread lock the data for update, other thread won't select out that locked data. Does it work?
    Thank you.
    Best regards,
    Andreas

    Why is the data submitted as a collection in the first place?
    A collection is great as a program data structure - dealing with program variables. It is a very poor choice to use it to deal with Oracle data in a CRUD fashion.
    The purpose, ito dealing with Oracle data, of a PL/SQL collection is for one thing and one thing only - context switching.
    To reduce the number of times you need to step out of PL/SQL and into the SQL engine in order to pass data from one to the other. A collection allows you a bigger buffer area and thus less context switches.
    And that's it.
    A client (Java, C#, etc) that submits data to Oracle to be CRUD via a collection is a design flaw. A collection resides in "expensive" dedicated, non-sharable and non-scalable server memory.
    In order to CRUD a collection, you either need to write bare bones feature methods yourself, or cast that collection into a SQL structure and use more powerful and flexible and feature rich SQL against it.
    Which then begs the question - why did the client not submit that data directly to the SQL engine, either into a permanent table or a temporary table?
    Performance and scalability are issues that need to be addressed at core design level. It is not something that can be tacked on and "fixed" after the fact. So you need to make very sure that your reasons for not wanting to use a temp table (for example), are valid and sound technical reasons.

  • How import prior Backed-Up Fox Favorities in multiple sub-folders rather than one at a time in Fox 6.0

    How do you import prior Backed-Up Fox Favorities. This involved many short-cuts and contained in multiple sub-folders.
    How can I import the whole folder library rather than one short-cut at a time from each folder.

    The favorites shortcuts were not IE but from Firefox. I had a operating system failure. So, after re-installing the operating system, I then had to re-install all applications anew.
    After installing Fox 6.0, the problem is my prior use of folders and sub-folders with many favorites shortcuts in each.
    It appears that I will need to start anew with creating a folder system in the new firefox application. Then take all of the favorites shortcuts, individually, out of folders and put them in a file in a row, in an antilog fashion. Then try to get Firefox to accept them in some fashion.
    I also do not know how to (1) export IE Favorites (2) in IE (3) to an HTML?
    I am just lost.
    Ijohn5

  • How can you delete multiple copies of the same songs without deleting one at a time?

    I have multiple copies of most of the songes in Itunes. How can I delete multiple copies without doing it one at a time?

    Select/highlight more than one at a time followed by selecting Delete.

  • HT5824 I have 4 calendars on my ICloud at work - I used to be able to view one calendar at a time or multiple - now when I check off to see just one calendar it automatically comes back on...?

    I have 4 calendars on my Icloud - I used to be able to view one at a time or multiple just by clicking on the check mark - now when I want to view just one calendar I click off the check mark but it automatically comes back on.  Any ideas?

    Can anyone help?

  • HP Photosmart all in one C309a printing multiple copies when its set to print only one copy.

    having issues with my C309a its now printing multiple copys when its set to print only one copy.it started doing this 4 days ago and its happening on both my Windows 7 64 bit computer and my Vista 32 computer that both have the latest release drivers already installed need help.HP please sort this issue out.still under warranty do i have to return it? 

    I am using a Motorola SBG900 Wirless Surfboard Gateway - supplied with Bigpond Cable. It is set to be using WPA security and have never had a problem with it before whilst connecting any wireless devices such as a laptop, PDA etc.
    My feeling is that the wireless functionality of this printer needs some serious work before the next release. And furthermore they should never have released it the way it is as it wouldn't pass 5% of user acceptance tests if using wireless. There are too many complaints on this forum and others about similar problems to suggest that I am not by myself here. Dissapointing considering this is the feature that would be at the top of the list of most purchasing this model. It lets down what could of been a vg printer.
    I agree, I think if I want to get this printer working on a wirless network, I will have to set the IP address manually. The problem is the printer refuses to connect to the router now even after it connected a few days ago with no intervention. I have powered down both the router, PC, and printer without any luck yet. I will set the IP address manually first on the printer and see how it goes, then if it connects will see if the PC/router can see the printer during the SW install procedure which has failed >10 times to date.
    For now I think I will stick with Ethernet as it is no doubt much faster anyway and will try the wirless setup again in a few days when my patience grows back. Does anyone know differences in speed between USB/Wireless/Ethernet? I know this is dependant on a number of things but just interested in ball park figures here.

  • TS1368 I want to delete a lot of things childrens stories, albums which are not used which that are on my ipad. However when I go through Itunes it wont show me most of the stuff in my library. it takes ages to delete one at a time.

    I want to delete a lot of things childrens stories, albums which are not used which that are on my ipad. However when I go through Itunes it wont show me most of the stuff in my library. it takes ages to delete one at a time.
    Can you help please?

    Thanks King_Penguin for taking time to read and reply. 
    I just purchased this movie on Thursday, May 15, so just a few days ago.  I have never had any trouble whatsoever since I have been in Vietnam.  I have downloaded several movies and even music and they have all synced to my respected Apple products except for this purchase. 
    Sorry, I don't quite understand what you mean by studios and different versions.  Could you please explain? 
    I checked my purchased list in my purchase history under my account and there are no hidden items. 

  • When I want to add an album onto my iphone using itunes, I am successful in  putting one album on my phone but when I want to add another album it deletes the first album I put on my phone. How can I add more albums without some albums disappearing?

    I am having a problem with importing cds onto my iPhone. I have successfully added a playlist or album to my phone but when I want to add another album/artist, the first album that was on there has all of a sudden disappeared. Its like I can only have one album on my phone. This is my first time dealing with anything Apple because I have been using android phones. Any help would be appreciated as I don't fully understand iTunes.

    You can delete photos from individual albums but not from the camera roll.  If you try to delete a photo from camera roll it will be deleted from all other albums ("locations") that contain the photo.  This is because the actual photo is in the camera roll (the albums only contain links to the photo in camera roll, not the actual photo).

  • Regarding iMessage, when i want to send text to a person in my contacts app, i've been getting a message saying the number has not been registered with iMessage.  How can one fix this problem?

    Regarding iMessage, when i want to send text to a person in my contacts app, i've been getting a message saying the number has not been registered with iMessage.  How can one fix this problem?  It works on the iPhone.

    It takes two to tango, maybe it's your recipient that has weak Internet/Cellular connections.

Maybe you are looking for

  • Quicktime 7.6.4 problem that might not have really been addressed yet

    Other than the export controller problem that has been mentioned before, in which the export controller stops working, I am having another problem with 7.6.4 that needs a solution. Well, to me, it looks like it has something to do with QuickTime 7.6.

  • Client Login to own album

    Hi everyone, Is it possible to login and display an album for a specific client? I have set up two tables client_login and Wedding_alb, which both contain the field client_id. Each client has an album of wedding images that I want them to be able to

  • Resolution for Widescreen Monitor question

    We have a project that requires a flash presentation that will run on a widescreen monitor (1366 x 768) at a tradeshow booth. Any advice on what resolution to use for our images? We had thought 150dpi would give us smooth color gradations. True? If w

  • Publish+Share best option for fast action AVI 1920x1080 29.97?

    I want to play my movie on an HDTV from my laptop or USB drive.  What is the best option for Publish+Share? I don't need to preserve layers for future re-edits and smaller file size is better but not if it's at the expense of playback quality.  Shoul

  • I have a problem and need help to proceed plz

    I'm working in all of the latest software. Long story short. Itunes is on my startup drive but I had my music folder on a larger external HD. It was selected in the prefs as the default media folder location. Unfortunately, the external HD with my mu