Results 1 to 3 of 3
  1. #1
    nuni is offline Member
    Join Date
    Jan 2016
    Posts
    1
    Rep Power
    0

    Default Waiting Until a Method is Finished

    Me and a partner are working on a project for a programming course. We're building a text based RPG with a main game mode GUI and Combat GUI. Every time we make an attempt to run the combat GUI the screen just appears blank and it is 100% unresponsive (it won't even close without stopping the program). Below is the called method. I'm not sure if there's anything that's directly in front of us that we can't see.
    Java Code:
    private void battleMode(){
            CombatLayout battle = new CombatLayout();
            battle.fight();
            CCT.combat = true;
            setVisible(false);
            while(CCT.combat == true){
                if(CCT.combat == false){
                    setVisible(true);
                    break;
                }
            }
        }

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    5,431
    Rep Power
    9

    Default Re: Waiting Until a Method is Finished

    Not much to go on but you are in a tight loop expecting some value to change and then catch it and exit the loop. You could be
    stuck in the event dispatch thread so your while loop will never see the change. But it is hard to tell. How much programming have you
    done using threads, events, timers, painting, frames, and networking? That (and probably more) is what you need to know to write the
    game you describe.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    124
    Rep Power
    0

    Default Re: Waiting Until a Method is Finished

    my first attempt would be to get rid of the infinite while loop and hook up an event to the change of that boolean variable.

Similar Threads

  1. Waiting for a method to call before continuing?
    By Xyexs in forum New To Java
    Replies: 8
    Last Post: 11-09-2013, 06:18 PM
  2. wait until method is finished
    By 3.14.TR in forum Threads and Synchronization
    Replies: 4
    Last Post: 12-04-2012, 10:28 PM
  3. Just finished Ch. 2 (need help)
    By Kurtis in forum New To Java
    Replies: 1
    Last Post: 10-08-2012, 03:37 AM
  4. Using Thread waiting() method
    By nicoeschpiko in forum New To Java
    Replies: 7
    Last Post: 12-11-2010, 09:24 PM
  5. Using Thread waiting() method
    By nicoeschpiko in forum Advanced Java
    Replies: 1
    Last Post: 12-11-2010, 04:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •