• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trigger a repaint from another method  RSS feed

 
Jenn Terry
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I have two classes. One constructs my a rectangle using Graphics2D (the class is called Rectangles). The second takes a user input for the triangle, which I am passing back to the first class. I am trying to trigger a repaint of class one from the action listener I have on a button in the second class. Can anyone tell me how to trigger this event?
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The second takes a user input for the triangle, which I am passing back to the first class


So i guess you already have a reference of first class in second class. So what is the difficulty in calling a method of first class using this reference? I hope I am not getting it wrong.
 
Jenn Terry
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've chased this for a couple of days with no luck. Here is some code to show a few things I have tried.

The center panel DComponent is what I'm trying to redraw.




In a different class, I have an button that I want to trigger the redrawing of the center panel as all the graphics in the panel will have changed dimensions. The following are my latest couple of attempts. For some unknown reason, I think I might be heading down the right track, but just not quite getting it correct.
 
Jenn Terry
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to get this to work. The problem was I was trying to apply repaint() to the wrong class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!