Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling repaint from another class

 
Keris Van Engeland
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i'm programming the game 'for on a row'. When someone makes for in a row I want to reset the game so you can start over. But I have a problem with calling the repaint method from another class.
Here is some code:





On line 50 in 'Vieropeenrij' I want to call the function 'nieuwSpel'. In this function I've put repaint() but this doesn't work.
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At line 34 you create a new Bord instance, and that is the one you call the method on. That is not the Bord which is being displayed, so it is not the one which would be painted/repainted (or display the game's state). You need to get a reference to the Bord which is actually displayed - not create a new one.
 
Keris Van Engeland
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And how can i make such a reference?
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keris Van Engeland wrote:And how can i make such a reference?

How do you get references for the spelerNaam1 and spelerNaam2 Strings?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic