Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / December 2005

Tip: Looking for answers? Try searching our database.

GUI program locking up...

Thread view: 
prolifekilledmywife@yahoo.com - 28 Dec 2005 21:16 GMT
I'm using Netbeans 5.0 beta for an IDE, with swing components. The
situation is something like this:

The program is a board game - the user chooses a building from a panel,
and then is supposed to get a message to choose what resource to pay
for it with.  Here's a trace of the code:

Game (main object):
      ....
      board[i].activate():
                     Game.game.setPlayer(worker);
                     Game.game.playerMessage("Choose a wooden building
from the building panel.");
                     Game.game.waitForBuild(type) :
                                      built = false;
                                      state = type + Game.BuildWood -
1;

mainPanel.buildings.getBP().setSelectedIndex(type-1);
                                      while(!built)
                                      { Thread.yield(); }
No problems yet.  This works fine, unless a building that needs to call
chooseResource is selected.
So, the user clicks one of these buildings, which activates the
following code, which is where the freeze occurs:

                    String r = Game.game.chooseResource():
                                   state = Game.chooseResource;
                                   resource = "";
                                   while(resource.length()==0)
Thread.yield();
                                   return resource;

Now chooseResource does work in any other context - resource gets set
by a mouseClicked event handler in a panel out there.  But at this
point, the GUI stops responding.  The playerMessage never gets printed,
and the click event never gets triggered.  I did some investigating,
printing out numbers inside the two inmost loops, and the
chooseResource loop is continually running.  I know the code's ugly,
but even so, the cause of this behavior is beyond me.  Any suggestions
would be greatly appreciated!
Chris Smith - 29 Dec 2005 00:15 GMT
> I'm using Netbeans 5.0 beta for an IDE, with swing components. The
> situation is something like this:

[...]

Please don't multipost.  I just wrote you an answer in a different
newsgroup.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.