Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Problem with running my second JFrame in a while loop

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everyone,
i have a client server application, where a player can select a board game like chess and play it. Therefore i have one JFrame for the menu, where the player can click a button for playing chess. If the player does so, the runChess() method gets called. in runChess() i setup the second frame for the board and i have a while(true) loop, for as long as the game is going on, i communicate with the sever, to update my GUI, check if its a valid move, etc.

the problem is, that my second frame does not load properly. it shows just a grey frame but does not load the board. if i break the while loop and runChess() terminates, then my frame is shown correctly.

Does anyone know how i can solve this problem showing my second frame correctly within the while loop?

 
Master Rancher
Posts: 4256
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you make and post here  a small program that compiles and executes to show the problem?
Be sure to wrap all posted code in code tags.


 if i break the while loop and runChess() terminates, then my frame is shown correctly.


Is the while loop executing on the EDT (the thread that the JVM uses to control the GUI)?
If your code is using the thread the GUI can not be updated.
 
Rancher
Posts: 3232
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cross posted: https://stackoverflow.com/questions/65271459/problem-with-running-my-second-jframe-in-a-while-loop
 
There's a city wid manhunt for this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic