How do i make the program hold after it has created a JFrame

I have created a JFrame with which the user shall login to a server. I call this JFrame from my main method (the JFrame-class is in a separate file). My problem is that after the login-window is created and set visible, my main method continues, i would like it to wait until the user have logged in before running the rest of the code.
this i my main method:
new LoginWindow();
System.out.println("Logged in: "+Session.isLoggedin()+
                "\nUsername: "+Session.getUsername());Session.isLoggedin() returns a boolean, true if user is logged in and otherwise false. class LoginWindow extends JFrame.
i have tried to use a while-loop to solve my problem:
while(!Session.isLoggedin()) { }and also
whiel(true){
    if(Session.isLoggedin())
        break;
}these while-loops never breaks, i have waited for about 3 min after successful login.It isn't because Session.isLoggedin() returns false, it does return true after a successful login (i've checked).
the funny thing however is if i print something in the while-loop i does break when login is finished
example:
whiel(true){
    System.out.println(Session.isLoggedin());
    if(Session.isLoggedin())
        break;
}this code makes the program wait until the login-phase is complete but i don't want it to print "text" a few thousand times while the user is logging in. (i've used "hej" as output aswell)
Since i have no idea how long it will take for a user to log in i can't use the System.sleep(value) method.
I would really appreciate any help
Thanks in advance
//Oscar

SnuShogge wrote:
I am still curious about why the while-loop only breaks if i print something using System.out.println(""), i didn't think that would make a difference since the break-statement remains the same.In general you should avoid trying to use while (true) or its variants in a Swing GUI as it often messes with the EDT, the main thread that renders the GUI graphics and interacts with the user.
My problem i however partially solved by using a JDialog instead of a JFrame. I am planning on using JFrame later in the program so the problem might come back to haunt me if it isn't solved.This may not be a great idea. Usually an application has one single JFrame. Most other distinct windows a dialogs of one sort or another and should be JDialogs, not JFrames. Often better still is to use a CardLayout to swap JPanels or other components.

Similar Messages

  • How can I make the popup with empty fileds and create new record?

    I would like to use a popup to create new record.
    I created a af:popup by drag and drop a VO from data control to jsff. then, I created a button and place a af:showPopupBehavior. I was able to popup window by click the button.
    however, the window filled with the information from the 1st record. and when I select a record in table and click popup, the popup is filled with that record.
    How can I make the popup with empty fileds and create new record by saving the popup?
    Thanks

    You can have edit and new buttons, in the PopupFetchEvent identify button source (using popupFetchEvent.getLaunchSourceClientId()) if new button clicked clear the binding using below code.
    If you want to see empty fields, in the popup PopupFetchEvent clear the input component bindings.
    resetBindingValue("#{bindings.<componentid>.inputValue}", null);
        public static void resetBindingValue(String expression, Object newValue) {
            FacesContext ctx = FacesContext.getCurrentInstance();
            Application app = ctx.getApplication();
            ExpressionFactory elFactory = app.getExpressionFactory();
            ELContext elContext = ctx.getELContext();
            ValueExpression valueExp = elFactory.createValueExpression(elContext,expression,Object.class);
            Class bindClass = valueExp.getType(elContext);
            valueExp.setValue(elContext,newValue);
        }

  • How do you make the program repeat itself?

    How would I make it so that when the if statement at the end of the code the program starts over from the begining?
    Any help appreciated. Here is the code if you wanna see it.
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    class SuperTester{
         public static void main ( String[] args ){
         // Create array that will hold deck
         Deck[] decko = new Deck[52];     
         // Fill the array with a deck
         decko = Deck.makeDeck();
         // Print new deck
         System.out.println( "PRINT NEW DECK" );
         System.out.println( "" );
         Deck.printDeck( decko );
         // Shuffle the deck ( simulated riffle shuffling )!
         decko = Deck.shuffleDeck( decko );
         // Print the shuffled deck
         System.out.println( "" );
         System.out.println( "PRINT SHUFFLED DECK" );
         System.out.println( "" );
         Deck.printDeck( decko );
         // Print first 5
         System.out.println( "" );
         System.out.println( "PRINT TOP 5" );
         System.out.println( "" );
         Deck.printFirstFive( decko );
         // Print single card
         System.out.println( "" );
         System.out.println( "PRINT SINGLE CARD" );
         System.out.println( "" );
         Deck.printCard ( decko [2] );
         System.out.println( "" );     
         BufferedReader in = new BufferedReader( new InputStreamReader (System.in));
         int input;
         System.out.println( " Do you want to re-run program? " );
         System.out.println( " Push 1 for yes " );
         System.out.println( " Push 2 for no " );
         System.out.println( "" );
    try
         input = Integer.parseInt( in.readLine() );
    catch( Exception e ){
    if ( input == 1 ){
    //WHAT DO I PUT HERE TO MAKE THE PROGRAM REPEAT ITSELF?
         } // end method
    } // end class

    So i should just do something like?
    int x = 0;
    while (x == 0){
    //code
    if (inpu == 1) {
        x == 0;
    }else{ x == 1; }                                                                                                                                                                                                                                                       

  • How do you make the program start?

    I have installed PSE 11 twice, now; the second time after an uninstallation of the first installation.  Both times, the program started immediately FROM the installation.  After exiting from the program, I have not been able to restart the program.  I click on it; I double click on it (which should start 2 copies of the program!); I right click and click Open; I right click and click "open as administrator".  Absolutely NOTHING happens.  Is there some sort of glitch that means you have to leave the program open permanently?  Please, how do I open the program? 
    Thank you.
    Cherie Brumfield

    Thanks so much for responding.  As it happens, I had already tried that
    approach, with no results.  I also spent some time last evening with a tech
    on the Adobe Chat page, also with no results.  So I just reloaded my PSE 8
    program, which does still work!  And this morning I get a notice of an
    Adobe update to PSE 11 and, guess what?!--NOW PSE 11 works just fine!!  Go
    figure!
    All of which has nothing to do with you having responded to my plea for
    help.  I really appreciate someone responding; it's nice to know that
    people "out there" really do care.  Thank you.
    Cherie
    On Wed, Feb 6, 2013 at 4:55 AM, bridge_mastero

  • How do i get the material type after submitting a create material request?

    Hi All,
    I have to select an agent depending on the material type of the material being created? I'm not using the rule based workflow for material creation in MDG 7.0, I'm using WS46000057. How do I get the material type being used in the workflow so that I can create a rule and select an agent accordingly from a custom table.
    Any kind of help would be sincerely appreciated.
    Regards,
    Tushar..

    Why not use the rule-based workflow template?
    Where do you want the material type? This is a standard workflow template and I'm not sure you can enhance it.
    In any case, in order to read CR details, you need to use the MDG API classes. These are described in this document: Master Data Governance Application Programming Interface Guide. Keep in mind that different API classes were developed for different releases so make sure to pick the class right for your release.

  • Everytime I try to open a creative cloud product, the program closes. I need to use both illustrator and indesign for school and I was wondering if anyone had any advice on how to actually make the program work?

    If anyone has any advice on how to make creative cloud programs work please let me know!
    Any help is appreciated.

    These questions below may be for a different product... but the KIND of information you need to supply is the same, for the products you use
    More information needed for someone to help... please click below and provide the requested information
    -Premiere Pro Video Editing Information FAQ http://forums.adobe.com/message/4200840

  • How i can make the code execute after file finish downloading

    Hi,
    i have a code that downloads a file
    then some code after , my problem is that code after does not wait to the file finish downloading
    how i can achieve that
    code is:
    String contentType = "application/x-download" ;
    FacesContext fc = FacesContext.getCurrentInstance();
    HttpServletResponse response =
    (HttpServletResponse)fc.getExternalContext().getResponse();
    response.setHeader("Content-Disposition",
    "attachment; filename=" + l_patch_name + ".zip");
    response.setContentType(contentType);
    try
    FileInputStream fis=new FileInputStream("c:\\patches\\"+ l_patch_name + ".zip");
    OutputStream os= response.getOutputStream();
    int byteRead;
    while(-1 != (byteRead = fis.read()))
    os.write(byteRead);
    os.close();
    if (fis != null)
    fis.close();
    catch(Exception e){
    DisplayMessage("Error in downloading the file");
    // now update the token
    OperationBinding operationBinding2 =
    bindings.getOperationBinding("UpdateTokenField");
    String UpdateTokenResult = (String)operationBinding2.execute();
    DisplayMessage(UpdateTokenResult);
    // now refresh the table
    OperationBinding operationBinding3 =
    bindings.getOperationBinding("RefreshPatches");
    Object result3 = operationBinding3.execute();

    Hi,
    the above code is excuted succesfully, but if i have
    return "Navigation" ;
    it is not working
    any idea why??????????

  • How can I make last slide "hold" after music is over

    I am doing a slide show for our pastor. I have adjusted the slide show to fit the music, but would like if to stay on the last slide instead of going back to the organizer window...any help?

    Hello bbcard1!
    I do not believe there is option to "hold" an image for a few extra ticks at the end of a slideshow by using iPhoto. You can accomplish this by using iMovie but that does require a learning curve.
    What I have done and is relatively simple, depending on the type of transitions you are applying, was to add the last image a couple extra times in the slide show. In my instance this worked rather well...
    Good luck, Rick

  • How can I make the frame advance after an flv is done playing?

    I've got an flv that we're streaming from a website and I
    want the swf to advance to the next frame once the video is done
    playing. I've looked all over for a way to do this, but I can't
    find anything. Does anyone know of some actionscript code that will
    work?
    Thanks.

    Nevermind. I figured it out for myself. I used this code
    right on top of the player itself.

  • How do I hide the admin button after someone has logged in as the administrator?

    Hi everyone,
    I am using Dreamweaver CS3, my question is:
    I have a login page that has check boxes at the bottom of the page that tell the database whether the user is an administrator or not.
    After the owner of the site has logged in as the administrator I would like to be able to hide the administrator button, can this be done with PHP, if so how do I do it?
    Thanks.

    Hello,
      Please try this:
    <?php
        function loggedin(){
            return isset( $_SESSION['loggedin'] );
        function require_login(){
            if( !loggedin() ){
                    header( 'Location: /login.php?referrer='.$_SERVER['REQUEST_URI'] );
                    exit;
    ?>
    Good Luck!
    Sean Colicchio
    Server Engineer
    hosting.com

  • How to make the document dirty after updating the links?

    Hi,
    I am using the below code to update the link resources by providing new URI. The link resources are getting updated, but the document is not becoming dirty.
                    InterfacePtr<ICommand> updateCmd(CmdUtils::CreateCommand(kLinkResourceStateUpdateCmdBoss));
                    InterfacePtr<ILinkResourceStateUpdateCmdData> updateCmdData(updateCmd, UseDefaultIID());
                    updateCmdData->SetResource(ref.GetUID());
                    updateCmdData->SetDatabase(ref.GetDataBase());
                    updateCmdData->SetNotify(true);
                    updateCmdData->SetUpdateAction(ILinkResourceStateUpdateCmdData::kUpdateURI);
                    updateCmdData->SetURI(newURI);
                    updateCmd->SetUndoability(ICommand::kRegularUndo);
                    CmdUtils::ProcessCommand(updateCmd);
    How do I make the document dirty after updating the resources?
    Thanks,

    Thanks. It is working fine.
    I called PreDirty(docPtr), before updating the links.

  • How do I make a program start up right when I turn my computer on?

    Hello all!
    Just wondering how I can make the program "iPulse" start right up when I turn my awesome computer on everyday!
    Thank you

    Add it to the list of login items for your account in the Accounts pane of System Preferences, or control-click/click and hold its Dock icon and set it to open at login.
    (34979)

  • How can I optimize the program's performance?

    Editing is going very slow. Audio runs normal but commands and video are delayed. Please let me know how I can make the program perform faster to avoid long edit sessions for simple tasks. My project is saved on a separate internal drive which has 3Tb of storage 99% free. I am running on the following computer (brand new):
    Windows 8
    ASUS Desktop PC M11BB Series
    Processor AMD A10-6700 APU with Radeon HD graphics 3.70 GHz
    Memory RAM 8.8 Gb (7.2 GB usable)
    System: 64-bit
    Please help me speed up the performance of Premiere Pro CC.
    Thanks,
    Jack

    A few things ...
    First, the video card ... while the ATI based cards can have awesome stats for general video playback in other programs or gaming purposes ... they're not the ones that Adobe utilizes the best in the three main video apps: PrPro, Speedgrade, & Ae/Fx. I'm also on a machine originally built for still-image processing utilizing AMD chipset & ATI/Radeon vid card. Was really wondrous for that ... but ssssslllllllllloooooooooooowwwwwww for video. I've a new machine 'designed" but not yet ordered/built (hope to get that done this next week) and the last discussion is that vid card ... my young tech-savvy friend/partner has designed what for the bucks should be an awesome machine ... but wants to put in an ATI card that has 4 gigs vRAM & good flow-through design. For total power within the design of his 'build" for my machine. I'm requesting an nVidia card that's only $40 more, has only 2GB vRAM ... but more memory 'cores' and about a 20% higher memory speed plus of course, being a CUDA card to make best use of the "Mercury Playback Engine" or MPE that Adobe uses to apply many of the effects to the footage as it plays on the program monitor during editing/grading/fx.
    I think your card might not be as optimal for Adobe vid programs as you would prefer.
    Next ... drives. HIGHLY recommended for Adobe vid-processing is a five-drive setup, all functioning at the speed of internal drives: 1) OS/programs; 2) cache; 3) footage; 4) projects; 5) output.
    This avoids read/write bottlenecks. It is also recommended that drives 1 & 2  be SSD's for fast in/outs, and suggested that 3 and 5 might be better on RAID 0 arrays ... again, for faster read/write speeds. The people who've modified their drive situation accordingly typically note a much better general working situation ... but also ...
    RAM ... 16 gigs is pretty minimal for decent operation, 32 better but only if your video card & drives are up to what I've mentioned above. On your machine perhaps the drives would be the first thing to upgrade ...

  • My husband uses adobe cs5. The clone tool isn't working and after resetting the tools adobe bridge now goes to picasa. How can we make the clone tool work and have bridge go to cs5 not picasa?

    My husband uses adobe cs5. The clone tool isn't working and after resetting the tools adobe bridge now goes to picasa. How can we make the clone tool work and have bridge go to cs5 not picasa?

    A lot more information about your hardware and software is needed.
    BOILERPLATE TEXT:
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CC", but something like CC2014.v.2.2) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    a screen shot of your settings or of the image could be very helpful too,
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • How can I make the iPhone podcast app automatically stop playing after one episode?

    How can I make the iPhone podcast app automatically stop playing after one episode?

    When playing a song, are the controls at the top of the screen there? (Genius, Shuffle, Loop?)
    If not, tap the center of the page once to expose them
    now keep tapping the circle on the left part of the exposed controls untill a one (1) appears...

Maybe you are looking for

  • Old MacBook Pro slow and hangs frequently, hard drive problems?

    Hi, I have an old Macbook Pro (one of the originals, from about 4 1/2 years ago). Recently I've been noticing that it runs really slow, especially when its been running for a while and there are multiple programs open. It will take a long time to swi

  • Set blocking price for lower tolerance limit

    Hello, when we try to park or post a vendor invoice in MIRO or MIR7 transactions we need to set the blocking price (RSEG-SPGRP) when the lower tolererance limit is reached. I have reviewed the OSS note 165589 but I think it is only for checking other

  • Issues in the import of Design & Configuration objects

    Hi SDNers, I have a small doubt. In one of our scenario we have exported the Design & Configuration objects (all objects) from DEV to ACC. But actually we want only selected objects to be imported into ACC. Will the import of objects under the same n

  • Adobe AIR and HTML5

    Hi, I am trying to run a HTML5 web application inside Adobe AIR, However it is unable to load the page. Other websites open fine. Does Adobe AIR support HTML 5? If yes, how do I get a HTML5 page to display in the frame? Thanks.

  • Launchpad won't let me switch page.

    I have two launchpad pages in my macbook. Whenever I try to browse to second page, it instantly scrolls me back to page 1. I am pretty sure, my keyboard and mouse isn't broken so it's not pressing or pushing any button. Only way I can access my apps