• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

repainting issue

I have an applet that pops out a dialogbox. now how can i repaint tha applet when this dialog box is removed. I have so far passed a reference of the applet to the dialogbox and tried to repaint (via {applet}.repaint() ) and then use the update(g) method to paintComponents(g) but it is not working...

even tried repaint(tm) but failed.

Help much appreciated
0
aKa
Asked:
aKa
  • 5
  • 4
1 Solution
 
heyhey_Commented:
applet is supposed to repaint itself - unless you block the event thread. do you perform any long task immediatelly after closing the dialog box (in the same thread) ?
0
 
aKaAuthor Commented:
yes...there is a long task after i close the dialog box...should i start the long task in a separate thread perhaps??

0
 
heyhey_Commented:
> should i start the long task in a separate thread perhaps??

absolutely

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
aKaAuthor Commented:
well that's something that is very difficult for me to implement. This is the program flow:

methodXX()
{
    [#1 perform some tasks, declare method variables]
   
   if(error==true)
   {
        popUpDialogbox()
   }
      [#2 continue task, involves setting and accessing method variables declared above]
}

so now if i include portion #2 in a thread, i can't possibly set any of the values in #1 right? since the run() method of the Runnable class is void, i can't return any value to the method either. Only way is to use static variables??

thanks a bomb for any advice!!
0
 
heyhey_Commented:
you can always do something like this


methodXX()
{
   [#1 perform some tasks, declare method variables]
 
  if(error==true)
  {
       popUpDialogbox()
  }

  TaskHandler handler = new TaskHandler();
  handler.val1 = ...;
  handler.val2 = ...;
  handler.start();
}


class TaskHandler extnds Thread
{
  public int val1;
  public String val2;
 
  public void run()
  {  
     // task 2
  }
   
}
0
 
aKaAuthor Commented:
right...!

blimey...you got my points!!

0
 
aKaAuthor Commented:
but how about passing values from the thread back to the method?
0
 
heyhey_Commented:
> but how about passing values from the thread back to the method?

just pass the result handler to the Task Thread

class TaskHandler extnds Thread
{
 public ResultHandler resultHandler;
 public int val1;
 public String val2;

 public void run()
 {
    // task 2
    resultHandler.taskCompleted(result);
 }
}
0
 
aKaAuthor Commented:
actually...i took an easier route....got the Sun Java Plugin and guess what...no more repainting problems!!!

cheers
thx for the help anyways
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now