Solved

repainting issue

Posted on 2002-05-06
9
217 Views
Last Modified: 2010-03-31
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
Comment
Question by:aKa
  • 5
  • 4
9 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 6991259
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
 

Author Comment

by:aKa
ID: 6992962
yes...there is a long task after i close the dialog box...should i start the long task in a separate thread perhaps??

0
 
LVL 16

Expert Comment

by:heyhey_
ID: 6993165
> should i start the long task in a separate thread perhaps??

absolutely

0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:aKa
ID: 6998030
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
 
LVL 16

Accepted Solution

by:
heyhey_ earned 100 total points
ID: 6998267
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
 

Author Comment

by:aKa
ID: 6998319
right...!

blimey...you got my points!!

0
 

Author Comment

by:aKa
ID: 6998323
but how about passing values from the thread back to the method?
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 6998432
> 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
 

Author Comment

by:aKa
ID: 7038360
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 58
expectj telnet failing 5 45
ejb wildfly example 2 20
Fast way to search item into Java Array (Rhino compatible) 2 31
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question