Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing panel in jframe getting problems  RSS feed

 
tajinder pal singh
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I got into one coding problem please help me out.

I want to switch panel on click of a button and code for switching panels is written in update method (Which gets called from notify observer of another class as part of Observer pattern.

unoGameController.playGame(playerFirst.getText(), playerSecond.getText());


playGame in Panel 1 of class 1 calls another class (class 2)and data comes in update method of class 1(Observer interface).
Now for switching panels code is in gameControllerDataProcessing . I am not able to switch the panels when this functionality runs.

However if i dont call the unoGameController.playGame(playerFirst.getText(), playerSecond.getText() and directly call the update method or directly write the switching panel code . then it works fine.



code snippet from update method :



I hope i made my problem clear. Apologise if the way i explained is not good .
Any valuable advice would be highly appreciated.Please let me know if i need to provide any more details. Thanks.
 
tajinder pal singh
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
am not sure just wild guess that this problem has something with Event's thread that Panel switching code should be called from main thread .

But my requirement demands it to be switched in update method .
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!