This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Calling repaint from another class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Calling repaint from another class" Watch "Calling repaint from another class" New topic
Author

Calling repaint from another class

Keris Van Engeland
Greenhorn

Joined: Apr 06, 2013
Posts: 2
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

Joined: Jan 28, 2003
Posts: 4164
    
  21

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.


Steve
Keris Van Engeland
Greenhorn

Joined: Apr 06, 2013
Posts: 2
And how can i make such a reference?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4164
    
  21

Keris Van Engeland wrote:And how can i make such a reference?

How do you get references for the spelerNaam1 and spelerNaam2 Strings?
 
Don't get me started about those stupid light bulbs.
 
subject: Calling repaint from another class
 
Similar Threads
mouseClicked and mouseDragged
A simple calculator help!
Can't Update Record ?
painting custom components without extending jcomponent
Can't Update Record ?